-
Linux 配置镜像加速
[root@k8s-master default]# vim /etc/docker/daemon.json
{“registry-mirrors”:[“https://registry.docker-cn.com”]} -
重启docker:
sudo systemctl daemon-reload
sudo systemctl restart docker -
查看docker配置:
sudo docker info

-
Docker 安装mysql
参考菜鸟教程: docker安装mysql: -
拉取mysql镜像:
docker pull mysql:latest -
查看镜像:
docker images -
运行mysql容器:
docker run -itd --name mysql-test -p 3307:3306 -e MYSQL_ROOT_PASSWORD=xxx mysql -
navicat连接报错:
2059 - Authentication plugin ‘caching_sha2_password’ cannot be loaded: dlopen(…/Frameworks/caching_ -
原因:
原因是mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password, -
解决:把mysql用户登录密码加密规则还原成mysql_native_password。
-
进入容器:
docker exec -it mysql-test /bin/bash -
进入mysql:
mysql -h localhost -u root -p -
添加新用户:
CREATE USER ‘xxx’@’%’ IDENTIFIED BY ‘yyy’; -
修改密码加密规则:
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘xxx’;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘xxx’;
ALTER USER ‘xxx’@’%’ IDENTIFIED WITH mysql_native_password BY ‘yyy’;
-
刷新权限
FLUSH PRIVILEGES; -
拷贝sql脚本到mysql容器中:
docker cp /home/grandsun/kuais_health/3292731_all.sql 046ca81a7644:/opt/ -
切换数据库:
use kuais_health; -
执行脚本:
source /opt/3292731_all.sql -
设置mysql的最大连接数
安装vim命令:
apt-get update
apt-get install vim
编辑配置文件
vim /etc/mysql/my.cnf
加入:
max_connections=1024
mysqlx_max_connections=1020
重启mysql:
docker restart 4c308c8c9377
方法二:
直接使用设置的方法:
set GLOBAL max_connections = 1024;
set GLOBAL mysqlx_max_connections = 1020;
次方法重启mysql之后,会失效;
-
退出mysql
quit -
退出mysql容器
exit