简体   繁体   English

django mysql数据库连接协议

[英]django mysql db connection protocol

How can I specify connection protocol in db OPTIONS? 如何在db OPTIONS中指定连接协议? If I use: 如果我使用:

'ENGINE': 'django.db.backends.mysql',
 ...
'OPTIONS': {
        'protocol': 'TPC',
    }, 

error is 'protocol' is an invalid keyword argument for this function 错误是'protocol' is an invalid keyword argument for this function

I'm trying to set OPTIONS as on Django docs and here is MySQL reference It is because I want to establish connection to remote db with ssh tunnel. 我正在尝试将选项设置为Django文档 ,这里是MySQL引用这是因为我想与ssh隧道建立到远程数据库的连接。

changing 改变

'HOST': 'localhost',

to

'HOST': '127.0.0.1',

fix the problem. 解决问题。 Using IP as host value driver is forced to use TPC protocol. 使用IP作为主机值驱动程序被迫使用TPC协议。 In the case of localhost it use local file socket which won't work through the tunnel. 在localhost的情况下,它使用本地文件套接字,它不能通过隧道工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM