docker 安装MySQL 8.0

使用docker安装MySQL 8.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#wget https://download.docker.com/linux/centos/docker-ce.repo
#yum -y install docker-ce
#systemctl restart docker
#docker pull mysql:8.0
#mkdir /data/mysql/{conf,data,log}
#docker run -p 3306:3306 --name mysql8 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:8.0
#docker cp mysql8:/etc/mysql /data/mysql/conf
#docker rm -f mysql8
#docker run \
-p 13306:3306 \
--name mysql8 \
--privileged=true \
--restart unless-stopped \
-v /data/mysql/log:/var/log/mysql \
-v /data/mysql/data:/var/lib/mysql \
-v /etc/localtime:/etc/localtime \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:8.0
#docker restart mysql8
1
2
3
4
5
6
7
8
9
#docker exec -it mysql8 bash
#mysql -uroot -p

>CREATE USER 'stack'@'%' identified by '123456';
>grant all on *.* to'stack'@'%';

更改root密码
>alter user 'root'@'localhost' identified by '123456';
>flush privileges;
1
>set global max_connections=1000;