美文网首页
docker安装mysql

docker安装mysql

作者: 晓码君 | 来源:发表于2018-10-06 16:21 被阅读0次
1. 获取mysql镜像
# docker pull mysql/mysql-server:latest
# docker images

2. 创建mysql容器
# docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=你的密码 -d mysql/mysql-server:latest

3. 启动mysql容器
# docker ps -s
# docker start mysql

4. 连接mysql测试
# docker exec -it mysql bash
# mysql -u root -p 
mysql> use mysql;
mysql> select host, user from user;

5. 开启远程访问(如有需要)
mysql> use mysql;
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';
mysql> GRANT ALL ON *.* TO 'root'@'%';
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
mysql> FLUSH PRIVILEGES; 
mysql> DELETE FROM user WHERE host <> '%' AND user = 'root';
参考文献

相关文章

网友评论

      本文标题:docker安装mysql

      本文链接:https://www.haomeiwen.com/subject/nsdhaftx.html