docker 安装mysql容器

发布时间:2023年12月18日


docker run -p 3307:3306 --name mysql-container -v /www/mysql/slave/log:/var/log/mysql -v /www/mysql/slave/data:/var/lib/mysql -v /www/mysql/slave/config/my.cnf:/etc/my.cnf -e MYSQL_ROOT_PASSWORD=Wenchen@xuan05186316 -e identified=mysql_native_password -d mysql:8.0.24
docker exec -it mysql-container

use mysql;
update user set host='%' where user='root' ;

grant all privileges on *.* to 'root'@'%' ;

flush privileges ;

select host from user where user='root';


alter user 'root'@'%' identified with mysql_native_password by 'Wenchen@xuan05186316';


select host, user, authentication_string, plugin from user


alter user 'root'@'%' identified with mysql_native_password by '123456';


docker run -d --name mysql-container -e MYSQL_ROOT_PASSWORD=123456 ?-p 3307:3306 -e identified=mysql_native_password mysql:8.0.24

create user 'slave21'@'%' identified with mysql_native_password by '1qaz@WSX3edc';

grant replication slave on *.* to 'slave21'@'%';

flush privileges;

show grants for 'slave21'@'%';


docker exec -it mysql-container mysql -u root -p

change master to master_host='172.17.0.1',master_user='slave21',master_password='1qaz@WSX3edc',master_log_file='mysql-bin.000022',master_log_pos=2900;

stop slave;

start slave;

show slave status \G

文章来源:https://blog.csdn.net/javaee_kekai/article/details/135001085
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。