[Solved] ERROR 1396 (HY000): Operation ALTER USER failed for ‘root‘@‘localhost‘

MySQL Connect database error:
1251 client does not support authentication protocol requested by server; consider upgrading Mysql client ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@’localhost’

Pre-registered mysql

mysql -u root -p

Input password

mysql> use mysql;
mysql> select user,host from user;

Note that my root and host are ‘%’
you may execute:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

Change to:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';

Operation record:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

Read More: