当前位置:网站首页>Docker install MySQL
Docker install MySQL
2022-07-19 11:28:00 【Tag heartbeat】
List of articles
Why use Docker install MySQL
1、docker Fast installation , Efficient ;
2、docker Good isolation , You can install countless mysql example , No interference with each other , As long as the mapping host port is different ;
3、 Less occupied resources ,MB Level , And the server installation GB Level ;
4、 Start speed seconds , And the server installation start minute level ;
5、 Performance close to native , The server installation is low ;
6、 The data backup 、 transfer ,docker More convenient and powerful ;
7、 Unloading management is more convenient and clean , Delete the container and image directly ;
8、 stability , Just promise docker There's no problem with the environment ,mysql Is no problem .
One 、 Installation steps
1. Pull the mirror image
Use here 5.7 Version as an example , If you want to install other versions, just change the version number , If you want to install the latest version, change the version number to latest
docker pull mysql:5.7

2. Create the mount file directory
# For storing logs
mkdir -p /srv/mysql/log
# Used to store application data
mkdir -p /srv/mysql/data
# Used to store MYSQL The configuration file
mkdir -p /srv/mysql/conf
3. Configure environment variables
export MYSQL_HOME=/srv/mysql
2. Start the mirror
docker run -d -p 3306:3306 --name mysql -v $MYSQL_HOME/log:/var/log/mysql -v $MYSQL_HOME/data:/var/lib/mysql -v $MYSQL_HOME/conf:/etc/mysql/conf.d/ -e MYSQL_ROOT_PASSWORD=123456 --restart=always --privileged=true mysql:5.7
-d Running the image in the background
-p 3306:3306 Will mirror the 3306 Port mapping to server's 3306 port .
--name mysql Give the container an alias
-v $MYSQL_HOME/log:/var/log/mysql Mount the log folder in the container to the corresponding /var/log/mysql In the folder
-v $MYSQL_HOME/data:/var/lib/mysql Mount the data folder in the container to the corresponding /var/lib/mysql In the folder
-v $MYSQL_HOME/conf:/etc/mysql/conf.d/ Mount the configuration folder of the container to the corresponding /etc/mysql In the folder
-e MYSQL_ROOT_PASSWORD=123456 take MySQL Password set to 123456
--restart=always Set the restart policy of the container to Docker Automatic restart on restart
--privileged=true Add specific permissions to the container . because Centos7 Security Selinux Some security permissions are prohibited , Lead to mysql and mariadb Mounting in progress /var/lib/mysql An error message will be prompted when
mysql:5.7 What is running MySQL Image name
3. View startup log
docker logs mysql

Two 、 Client connection
Use here Navicat Premium16 Tool for connection test :
host : install MySQL The public network of the machine IP
port :3306( Default )
user name :root( Default )
password :123456

边栏推荐
- Second classification learning is extended to multi classification learning
- [Huawei cloud IOT] reading notes, "Internet of things: core technology and security of the Internet of things", Chapter 3 (2)
- TCP拥塞控制详解 | 7. 超越TCP
- STC8H开发(十四): I2C驱动RX8025T高精度实时时钟芯片
- CodeForces - 587E(线性基+线段树+差分)
- Powercli script performance optimization
- Introduction to the universal theme system of SAP appgyver
- Will causal learning open the next generation of AI? Chapter 9 Yunji datacanvas officially released the open source project of ylarn causal learning
- The difference between CPU load and CPU utilization
- Leetcode 1304. 和为零的 N 个不同整数
猜你喜欢

Configuration of vscode+unity3d

Mysql优化系列之limit查询

Category imbalance in classification tasks

LeetCode 745. 前缀和后缀搜索

LeetCode 745. Prefix and suffix search

开发那些事儿:如何解决RK芯片视频处理编解码耗时很长的问题?

Limit query of MySQL optimization series

Detailed explanation of multiple linear regression

A fastandrobust volutionalneuralnetwork based defect detection model inproductqualitycontrol reading notes

jconsole线程面板中的阻塞总数和等待总数(转)
随机推荐
Dream CMS Front Office Search SQL Injection
SPI service discovery mechanism
Introduction to virtualization troubleshooting
Leetcode 1328. 破坏回文串(可以,已解决)
565. 数组嵌套 : 常规模拟题
Automated graphical interface library pyautogui
Goldfish rhca memoirs: cl210 describes the openstack control plane -- identify the overcloud control platform service + chapter experiment
Unity dropdown (editable, inputable) drop-down selection box with Text Association
Use and principle of ThreadLocal variable
zabbix代理服务器配置
Hot discussion: my husband is 34 years old this year and wants to read a doctoral degree. What should I do in the future to do scientific research?
Chapter 1 of creating virtual machine (vmvare virtual machine)
A curated list of awesome Qt and QML
AT5147-[AGC036D]Negative Cycle【dp,模型转换】
Qt--优秀开源项目
早期单片机加密的一些方法 【评论区领取资料】
要想组建敏捷团队,这些方法不可少
A summary of C language pointer
Sword finger offer II 041 Average value of sliding window
Tire Defect Detection Using Fully Convolutional Network-论文阅读笔记