23

When I am trying to connect with mysql 8.0 I am getting this error. How can I fix this ?

code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; 
consider upgrading MySQL client',
sqlState: '08004',
fatal: true
Kamil Gosciminski
  • 16,547
  • 8
  • 49
  • 72
Rupesh
  • 840
  • 1
  • 12
  • 26
  • What's the auth protocol requested by the server and which one you are using - that's where you should look for – Kamil Gosciminski Jun 24 '18 at 10:00
  • @Rupesh: change the `plugin` field as well because it was set to 'auth_socket'. `use mysql; update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';` Check this link: [Click here](https://stackoverflow.com/questions/44946270/er-not-supported-auth-mode-mysql-server) – Manav Jun 24 '18 at 10:15
  • Solution https://stackoverflow.com/questions/2101694/how-to-set-root-password-to-null/36234358#36234358 – prashant0205 Jun 24 '18 at 10:21
  • @Manav I am using mysql 8.0.11 and I have tried `mysql> use mysql; Database changed mysql> update user set password=PASSWORD("helloworld") where User='root';` And it says: `ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '("helloworld") where User='root'' at line 1` – Rupesh Jun 24 '18 at 20:32
  • Please check your syntax/code. Error is related to this. [Click here](https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/resetting-permissions-windows.html) – Manav Jun 25 '18 at 09:28
  • Possible duplicate of [Node.js can't authenticate to MySQL 8.0](https://stackoverflow.com/questions/50373427/node-js-cant-authenticate-to-mysql-8-0) – klutt Nov 25 '18 at 00:47
  • Possible duplicate of [MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client](https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server) – Yuri Predborski Apr 15 '19 at 09:58
  • See answer here: https://stackoverflow.com/a/74458804/3944673 – Lorraine R. Mar 22 '23 at 15:13

2 Answers2

50

Try change the password as below:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your new password'; 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your new password';
Nick
  • 138,499
  • 22
  • 57
  • 95
TIAGO SILVA
  • 501
  • 4
  • 3
  • 2
    Great answer! This solved my problem! Can you please explain why this works? – Jessica Jul 31 '19 at 04:38
  • 4
    @Jessica MySQL 8.0 uses caching_sha2_password as default authentication plugin rather than MySQL 5.7 default mysql_native_password, supported by most clients, which is why you need to explicitly allow that authentication for given user: ALTER USER 'user' IDENTIFIED WITH mysql_native_password BY 'password' – iki Sep 17 '19 at 11:12
13
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

FLUSH PRIVILEGES;

"password" is that you have to change the password you already have or you will modify it for a new one

Community
  • 1
  • 1
AN German
  • 725
  • 10
  • 10