Docker容器DockerDocker

Docker安装Mysql服务

2018-10-24  本文已影响13人  Rethink
  1. 拉取官方镜像
# docker pull mysql
# docker inspect mysql | grep ''VERSION''
            "GOSU_VERSION=1.7",
            "MYSQL_VERSION=8.0.11-1debian9"
            "GOSU_VERSION=1.7",
            "MYSQL_VERSION=8.0.11-1debian9"
  1. 运行容器
# docker run -it -d 
  -p 13306:3306 
  --name db_mysql 
  --restart=always 
  -e MYSQL_ROOT_PASSWORD=root 
  -v /opt/docker/mysql/log:/var/log/mysql 
  -v /opt/docker/mysql/data:/var/lib/mysql 
  -v /opt/docker/mysql/conf:/etc/mysql/conf.d 
  mysql 
  1. 查看容器日志
'查看最后200条日志'
# docker logs --tail=200 db_mysql
'滚动监听'
# docker logs -f db_mysql
  1. 配置Mysql
# docker exec -it db_mysql sh
# mysql --version
mysql  Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL)
# mysql -uroot -proot
mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
mysql> ALTER USER 'root'@'%' identified by 'your_passwd';
mysql> FLUSH PRIVILEGES;
  1. 远程连接测试
mysql -h SEREVR_IP -P 13306 -uroot -p
上一篇下一篇

猜你喜欢

热点阅读