mysql: Error: ER_NOT_SUPPORTED_AUTH_MODE with auth_socket

Yesterday I upgraded my ubuntu distribution an MySql Server was updated too. But when I connect I get this error Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

My connection code:

var mysql = require('mysql');
var connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: '',
  database: 'test_db',
  // insecureAuth : true,
});

connection.query('SELECT * FROM users', function(err, rows, fields) {
  if (err) throw err;
});

I tried to set insecureAuth: true but no changes

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 6
  • Comments: 29 (12 by maintainers)

Most upvoted comments

Problem solved!

use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';

http://stackoverflow.com/a/36234358/1431224

Changing plugin to mysql_native_password solved the problem 😃!

https://github.com/mysqljs/mysql/issues/1507#issuecomment-242885003 worked for me. Don’t forget to flush privileges; after.

Actually I didn’t try to figure out what was the old value, I just liked the part when I changed the plugin then it worked 😄

Thanks all guys for your concern

This one worked for me:

docker exec -it YOUR_CONTAINER mysql -u root -p
Enter password:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '{your password}';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{your password}';
SELECT plugin FROM mysql.user WHERE User = 'root';

Just ran into the same issue.

The root user by default (if you didn’t set any password during installation) appears to be:

mysql> select Host,User,plugin,authentication_string from user where User='root'\G
*************************** 1. row ***************************
                 Host: localhost
                 User: root
               plugin: auth_socket
authentication_string: 
1 row in set (0.00 sec)

In my case, I solved the problem by fixing my nodejs code to stop using root user to connect.

Haha, we all replied at the same time 😃 I’m not sure why mine worked out of the box, but glad to get this figured out.