docke部署mysql

时间:2022-04-24 05:15:10

#1    docker pull mysql

#2    docker run -v /data/var/mysql/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=kS4pJUIb mysql

#3    docker stop [CONTAINER ID]

#4    docker run -it -v /data/var/mysql/:/var/lib/mysql mysql /bin/bash

#5    mysqld_safe&

#6    mysql -u root -p

#7    grant all privileges on *.* to 'wuxiao'@'%' identified by 'password';

#8    docker cp [CONTAINER ID]:/etc/mysql/my.cnf /data/local/my.cnf

#9    docker stop [CONTAINER ID]

#10    docker run -d -p 3306:3306 -v /data/var/mysql/:/var/lib/mysql -v /data/local/my.cnf:/etc/mysql/my.cnf mysql

#11    add [CMD] to  /etc/rc.local

#12    OK!