Django/MySQL-python - Connection refused using old (pre-4.1.1) authentication protocol (client option "secure_auth" enabled)


sleepy

So many people have experienced this problem, but almost all the answers are useless.

Traceback (most recent call last):
  File "/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/venv/local/lib/python2.7/site-packages/django/core/management/validation.py", line 103, in get_validation_errors
    connection.validation.validate_field(e, opts, f)
  File "/venv/local/lib/python2.7/site-packages/django/db/
backends/mysql/validation.py", line 14, in validate_field
    db_version = self.connection.get_server_version()
  File "/venv/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 415, in get_server_version
    self.cursor().close()
  File "/venv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 306, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/venv/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 387, in _cursor
    self.connection = Database.connect(**kwargs)
  File "/venv/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/venv/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2049, "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")
sleepy

After a lot of trial/error, the problem was still narrowed down to a password using the old encryption.

mysql> select User, Password from mysql.user;
| user1           | *113D91F3A36D29C287C457A20D602FA384B8569F |
| user2           | 5d78f2535e56dfe0 |

A tool like Navicat doesn't automatically use newer style passwords, and you have to explicitly tell it not to use the old style (in Navicat it's called Advanced/Use OLD_PASSWORD tncryption) - this is where we come across.

If you are using the mysql shell, you can use;

mysql> update mysql.user set password=PASSWORD("NEWPASSWORD") where User='testuser';
Query OK, 1 row affected
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select User, Password from mysql.user WHERE user = 'testuser';
| testuser | *B845F78DCA29B8AE945AB9CFFAC24A9D17EB5063 |

If you want to find all users affected by this issue;

mysql> SELECT Host, User, Password FROM mysql.user WHERE LENGTH(Password) = 16;

Some versions of Django don't allow you to use secure-authinside options , but for those that do, you can use these options.

'OPTIONS': {
    'secure-auth': False
}

If not supported, will result in:

TypeError: 'secure-auth' is an invalid keyword argument for this function

Hope this provides a quick answer for anyone having trouble in the future.

Related


1and1 SSH - Connection refused

Kitensei I'm having trouble connecting to my 1&1 account via SSH. when i try to connect using the command userXXX@host -p22 -vv I have the following output: OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011 debug1: Reading configuration data /etc/ssh/s

1and1 SSH - Connection refused

Kitensei I'm having trouble connecting to my 1&1 account via SSH. when i try to connect using the command userXXX@host -p22 -vv I have the following output: OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011 debug1: Reading configuration data /etc/ssh/s

How to pass secure_auth to MySQL login via SQLalchemy

Dave Everett I'm working on the front end of a web application and my co-developer is using Pyramid and SQAlchemy. We just migrated from SQLite to MySQL. I installed MySQL 5.6.15 (via Homebrew) on an OS X machine in order to install Python MySQLdb (via pip in

C server - Python client. connection refused

Anton Zakharov: I'm new to Socket, please forgive me for my complete ignorance. useless_server.c: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> int main(void) { int sd;

C server - Python client. connection refused

Anton Zakharov: I'm new to Socket, please forgive me for my complete ignorance. useless_server.c: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> int main(void) { int sd;

C server - Python client. connection refused

Anton Zakharov: I'm new to Socket, please forgive me for my complete ignorance. useless_server.c: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> int main(void) { int sd;

Client socket connection refused

Net Fox I'm trying to understand how sockets work in Java, so I want to look at a client-server implementation. I found this: Creating a Simple Java TCP/IP Server and Client Socket . If I pass, the server seems to work, localhostor 127.0.0.1the client will ref

neo4j graphaware php-client: Connection refused

Janiz I am running XAMPP locally on my MacBook. On the same computer, I run neo4j Enterprise. The database is version 3.5.6. When I try to connect to the database through the php client, I get a warning and a fatal error: Warning: stream_socket_client(): Faile

neo4j graphaware php-client: Connection refused

Janiz I am running XAMPP locally on my MacBook. On the same computer, I run neo4j Enterprise. The database is version 3.5.6. When I try to connect to the database through the php client, I get a warning and a fatal error: Warning: stream_socket_client(): Faile

neo4j graphaware php-client: Connection refused

Janiz I am running XAMPP locally on my MacBook. On the same computer, I run neo4j Enterprise. The database is version 3.5.6. When I try to connect to the database through the php client, I get a warning and a fatal error: Warning: stream_socket_client(): Faile

neo4j graphaware php-client: Connection refused

Janiz I am running XAMPP locally on my MacBook. On the same computer, I run neo4j Enterprise. The database is version 3.5.6. When I try to connect to the database through the php client, I get a warning and a fatal error: Warning: stream_socket_client(): Faile

neo4j graphaware php-client: Connection refused

Janiz I am running XAMPP locally on my MacBook. On the same computer, I run neo4j Enterprise. The database is version 3.5.6. When I try to connect to the database through the php client, I get a warning and a fatal error: Warning: stream_socket_client(): Faile

Selenium remote connection refused using Python Fragmentation

KMK I am trying to test the browser. Unfortunately, it doesn't seem to be able to connect to the website. Once done manually, the site opens fine in the browser. Did I forget something? I followed the example on the shard documentation site. my python code: fr

Selenium remote connection refused using Python Fragmentation

KMK I am trying to test the browser. Unfortunately, it doesn't seem to be able to connect to the website. Once done manually, the site opens fine in the browser. Did I forget something? I followed the example on the shard documentation site. my python code: fr

Connection refused: localhost/0:0:0:0:0:0:0:1:9000 using gRPC

Isaac I created a gRPC server, but everything seems to work fine, but the server never starts on the port specified and the application throws no errors. However, when I test with telnet on that particular port, I get from the terminal isaack$ telnet localhost

Connection refused: localhost/0:0:0:0:0:0:0:1:9000 using gRPC

Isaac I created a gRPC server, but everything seems to work fine, but the server never starts on the port specified and the application throws no errors. However, when I test with telnet on that particular port, I get from the terminal isaack$ telnet localhost

How to block old version of TLS protocol in python openssl client

User 9371654 I need my python TLS client to provide only TLS 1.2 version (disabled TLS 1.0, TLS 1.1, SSLv3, SSLV2). I am using python 3.6.5 and openssl library under windows 10. According to the official documentation here , these two lines should prevent both

How to block old version of TLS protocol in python openssl client

User 9371654 I need my python TLS client to provide only TLS 1.2 version (disabled TLS 1.0, TLS 1.1, SSLv3, SSLV2). I am using python 3.6.5 and openssl library under windows 10. According to the official documentation here , these two lines should prevent both

How to block old version of TLS protocol in python openssl client

User 9371654 I need my python TLS client to provide only TLS 1.2 version (disabled TLS 1.0, TLS 1.1, SSLv3, SSLV2). I am using python 3.6.5 and openssl library under windows 10. According to the official documentation here , these two lines should prevent both

Mosquito client gets connection refused

Luca Davanzo: I want to use MQTT protocol through mosquitto library. First, I want to do some testing install mosquitto-clients sudo apt-get install mosquitto-clients The program provides two "methods": mosquitto_pub mosquitto_sub Following this instruction,

Mosquito client gets connection refused

Luca Davanzo I want to use MQTT protocol through mosquitto library. First, I want to do some testing install mosquitto-clients sudo apt-get install mosquitto-clients The program provides two "methods": mosquitto_pub mosquitto_sub Following this instruction,

Mosquito client gets connection refused

Luca Davanzo: I want to use MQTT protocol through mosquitto library. First, I want to do some testing install mosquitto-clients sudo apt-get install mosquitto-clients The program provides two "methods": mosquitto_pub mosquitto_sub Following this instruction,

Create a new string from an old string using python(1)

username My function has three string parameters, string, search and replace. If the search argument is an empty string, the function should insert replaceable arguments before the first argument, between each character of the old string, and after the last ch

Create a new string from an old string using python(1)

username My function has three string parameters, string, search and replace. If the search argument is an empty string, the function should insert replaceable arguments before the first argument, between each character of the old string, and after the last ch