Blog Pages

Can't connect to MySQL 8.0 because a plugin error

The case:
Can't connect to MySQL 8.0 because a plugin error

Error message:

FATAL: unable to connect to MySQL server on host '10.4.117.147', port 3306, aborting...
FATAL: error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
FATAL: 'sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation failed

Cause:
The main cause is that the user has password plugin as "mysql_native_password" but authentication_string contains different hash in mysql.user table.

Solution:

UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'USERNAME';
FLUSH PRIVILEGES;
UPDATE mysql.user
SET authentication_string=concat('*',upper(sha1(unhex(sha1('USERNAME')))))
WHERE user='USERNAME';
FLUSH PRIVILEGES;

1 comment: