[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