2

How can I specify connection protocol in db OPTIONS? If I use:

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

error is '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.

4
  • Are you sure the option is valid? I did a short check and did not found it on documentation -- maybe valid though, but just wondering Commented Feb 23, 2017 at 7:27
  • @frlan I think it isn't. I don't know how to specify protocol except in OPTIONS Commented Feb 23, 2017 at 7:37
  • So going a step further: Why you want to define TCP? TCP should be the default anyway we are connection not by socket, but via IP Commented Feb 23, 2017 at 9:03
  • @frian well I'm trying to establish connection via ssh tunnel and access to the db remotely. When I'm connected to the server, in the terminal I must specify --protocol=TPC to establish connection with remote mysql db. mysql -u X -pXX -h localhost --protocol=TCP XX Commented Feb 23, 2017 at 15:51

1 Answer 1

7

changing

'HOST': 'localhost',

to

'HOST': '127.0.0.1',

fix the problem. Using IP as host value driver is forced to use TPC protocol. In the case of localhost it use local file socket which won't work through the tunnel.

Sign up to request clarification or add additional context in comments.

1 Comment

I have been bitten by this too! Thanks for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.