MySQL 8报错:Authentication plugin 'caching_sha2_password' cannot be loaded

时间:2022-06-01 13:04:14

使用MySQL Workbench连接MySQL服务器时报错:

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found

Windows

方法一:

进入mysql shell:

cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
C:\Program Files\MySQL\MySQL Server 8.0\bin> mysql -u root -p
Enter password: *********
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newrootpassword';
Query OK, 0 rows affected (0.10 sec)
mysql> exit

方法二:

打开my.ini配置,

[mysqld]
default_authentication_plugin=mysql_native_password

重启MySQL服务器

Linux

可以像Windows在mysql终端处理,也可以在配置文件中,如/etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
    default_authentication_plugin=mysql_native_password