Docker安装Mysql服务

  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
上一篇:2018-10-28


下一篇:数据仓库的工作日记_创纪录的(一)