docker + mysql
  • 启动
docker run -p 3306:3306 --name mysql \
-v ~/mysql/conf:/etc/mysql \
-v ~/mysql/logs:/var/log/mysql \
-v ~/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.7.28
docker exec mysql whereis mysql
docker exec mysql ls /etc/mysql
docker cp mysql:/etc/mysql/my.cnf ~/mysql/conf/
  • 链接 mysql
docker exec -it mysql bash
mysql -uroot -p123456
use mysql
select user,authentication_string from user;
update user set authentication_string='' where user='root';
alter user 'root'@'%' IDENTIFIED BY '[email protected]';
alter user 'root'@'localhost' IDENTIFIED BY '[email protected]';
flush privileges;
host: 127.0.0.1
port: 3306
user: root
password: 123456
  • 修改密码
docker exec -it mysql bash
mysqladmin -uroot -p123456 password 123
Copy link