Docker 安装 MySQL5.7
2021/9/29 19:12:15
本文主要是介绍Docker 安装 MySQL5.7,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
转自:https://www.cnblogs.com/418836844qqcom/p/11692237.html
1.安装mysql5.7 docker镜像:
docker pull mysql:5.7
2.查看镜像库:
docker images
3. 在本地创建mysql的映射目录
mkdir -p /root/mysql/data /root/mysql/conf /root/mysql/logs
4.在/root/mysql/conf中创建 mysqld.cnf文件,并添加配置文件内容
cd /root/mysql/conf vi mysqld.cnf
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 lower_case_table_names=1 init_connect='SET collation_connection = utf8_general_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_general_ci max_connections = 1000
5.创建容器,将数据,日志,配置文件映射到本机
docker run --name mysql -p 3306:3306 --restart=always -e MYSQL_ROOT_PASSWORD=root -v /root/mysql/conf/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /root/mysql/data:/var/lib/mysql -v /root/mysql/log:/var/log/mysql -d mysql:5.7
这篇关于Docker 安装 MySQL5.7的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程