[root@localhost opt]# mysql -uroot -p
Enter password:
ERROR 2002(HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[root@localhost opt]#
[root@master ~]# docker cp mysql:/usr/bin/mysql /usr/bin/mysql
Successfully copied 7.72MB to /usr/bin/mysql
[root@master ~]# mysql -uroot -p
mysql: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
[root@master ~]#
[root@master ~]# mysql -version
ERROR 2002(HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[root@master ~]#
同理mysqldump也是一样的做法大约24M,放到指定目录/usr/bin下即可
2-2:如果提示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,就需要在创建容器的时候设置–default-authentication-plugin=mysql_native_password
docker run -d--name mysql --net=host -v ./mysql/data:/var/lib/mysql -eMYSQL_ROOT_PASSWORD=root mysql:8.0 --default-authentication-plugin=mysql_native_password
docker run -d--name mysql --net=host -v /opt/app/mysql/data:/var/lib/mysql -eMYSQL_ROOT_PASSWORD=root mysql:8.0 --default-authentication-plugin=mysql_native_password