問題處理:Authentication plugin 'caching_sha2_password' cannot be loaded


[root@linux-node1 ~]# docker container ls

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07fa2525865e mysql "docker-entrypoint.s…" 22 seconds ago Up 20 seconds 0.0.0.0:3306->3306/tcp lnmp_mysql
0e12363c63ef nginx:v1 "./sbin/nginx -g 'da…" 16 hours ago Up 16 hours 0.0.0.0:888->80/tcp lnmp_nginx
d7c49b7e7a95 php:v1 "./sbin/php-fpm -c /…" 17 hours ago Up 17 hours 9000/tcp lnmp_php


[root@linux-node1 ~]# mysql -h10.0.0.80 -uroot -p
Enter password:
ERROR 2059 (HY000): 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
在客戶端登錄失敗!
原因:密碼加密方式【caching_sha2_password】,客戶端不支持。

在數據庫服務器上登錄解決:
[root@linux-node1 ~]# docker exec -it 07fa2525865e bash
root@07fa2525865e:/# ls
bin dev entrypoint.sh home lib64 mnt proc run srv tmp var
boot docker-entrypoint-initdb.d etc lib media opt root sbin sys usr
root@07fa2525865e:/# my
my_print_defaults mysql mysql_upgrade mysqld_safe
myisamchk mysql_secure_installation mysqlbinlog mysqldump
myisamlog mysql_ssl_rsa_setup mysqld mysqlpump
myisampack mysql_tzinfo_to_sql mysqld_multi
root@07fa2525865e:/# mysql --version
mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL)
root@07fa2525865e:/# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@07fa2525865e:/# mysql -uroot -p
Enter password: 123456

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> select user,host,plugin,authentication_string from user\G;
*************************** 1. row ***************************
user: root
host: %
plugin: caching_sha2_password
authentication_string: $A$005$SR^S?+P#k0z D9wrLWoXHO8gsIz5zNMbo3i4IxiGh.KpIBHIEhMKq7N2
*************************** 2. row ***************************
user: mysql.infoschema
host: localhost
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
*************************** 3. row ***************************
user: mysql.session
host: localhost
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
*************************** 4. row ***************************
user: mysql.sys
host: localhost
plugin: mysql_native_password
authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
*************************** 5. row ***************************
user: root
host: localhost
plugin: caching_sha2_password
authentication_string: $A$005$!&F^+?XhJ;pYSTJk/iSOOdmGobDUyOoDpYJ2Ym34.kMM6rDDf.BVsZXfeYB
果然 root 的密碼是用 caching_sha2_password 插件加密的。而客戶端找不到 caching_sha2_password 插件,於是登錄不上。我第一反應是給客戶端安裝相應插件,然而看了官文檔:
sha2_cache_cleaner, likecaching_sha2_password,插件是內置的,不需要安裝。root用戶 在安裝數據庫是,指定的加密插件是:caching_sha2_password,應該是我的安裝沒修改安裝配置文件。
於是我要修改root用戶的加密插件,因為用新添加的用戶需要去授權,請原諒我的懶,一個牛B的前輩說過,不懶的程序員都不是一個好的程序員。
修改root用戶密碼:
mysql> alter user 'root'@'%' identified with mysql_native_password by 'root';
mysql> flush privileges;

測試成功:
[root@linux-node1 ~]# mysql -h10.0.0.80 -uroot -p
Enter password: root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>


--------------------------
解決:
[root@linux-node1 ~]# head -3 /etc/my.cnf
[mysqld]
#meng add
default_authentication_plugin=mysql_native_password

[root@linux-node1 ~]# rpm -qa | grep mysql*
mysql-connector-python-1.1.6-1.el7.noarch
mysql-mmm-monitor-2.2.1-14.el7.noarch
mysql++-manuals-3.1.0-12.el7.x86_64
mysql-proxy-devel-0.8.5-2.el7.x86_64
mysql-proxy-0.8.5-2.el7.x86_64
mysql-mmm-tools-2.2.1-14.el7.noarch
mysql-mmm-agent-2.2.1-14.el7.noarch
mysql++-devel-3.1.0-12.el7.x86_64
mysqlreport-3.5-11.el7.noarch
mysql-connector-odbc-5.2.5-6.el7.x86_64
mysql++-3.1.0-12.el7.x86_64
mysql-mmm-2.2.1-14.el7.noarch
mysql-connector-java-5.1.25-3.el7.noarch
mysql-utilities-1.3.6-1.el7.noarch
mysqltuner-1.6.0-1.el7.noarch
[root@linux-node1 ~]# yum install -y mysql*

------------------------
安裝 mysql 8.0后;root用戶在客戶端連接不上
http://binary-space.iteye.com/blog/2412769


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM