当前位置:网站首页>Install mysql using docker
Install mysql using docker
2022-08-02 02:15:00 【m0_54850825】
1. View the name of the mysql image to download on docker hub:
The docker hub image repository is for us to develop
Open the docker hub website
dockerHub official website address
Enter mysql in the search bar above
Take the image version, find the version under the tag
BackGo to the virtual machine interface and execute the following command to pull the mysql image
Do not specify the version number, download the latest version by default:
sudo docker pull mysql
Specify version number:
sudo docker pull mysql:5.7
2. After the image is pulled, use the image to create a mysql instance, and use the following command to create
sudo docker run-p 3306:3306 --name mysql-v /mydata/mysql/log:/var/log/mysql-v /mydata/mysql/data:/var/lib/mysql-v /mydata/mysql/conf:/etc/mysql-e MYSQL_ROOT_PASSWORD=root-d mysql:5.7
Here is a brief introduction to the above parameters. If you don't want to understand this piece, just copy the above command and execute it:
Configure port mapping:
-p 3306:3306--name mysql
Map port 3306 of the container to port 3306 of the host
Configure mysql data volume mount
1.-v /mydata/mysql/log:/var/log/mysql (log file mount)
Mount the log folder in the container to the /var/log/mysql folder corresponding to the host
2.-v /mydata/mysql/data:/var/lib/mysql (data file mount)
Mount the data folder in the container to the /var/lib/mysql folder corresponding to the host
3.-v /mydata/mysql/conf:/etc/mysql (configuration file mount)
Mount the configuration folder of the container to the /etc/mysql folder corresponding to the host
Note (the host mentioned here refers to the current linux host)
Configure user
-e MYSQL_ROOT_PASSWORD=root
Set the password of the initial root user
Specify the mirror resource
-d mysql:5.7
-d: run the instance in the background
mysql:5.7: specify this image to create a running instance
The following demonstration is to execute the command with the root user. If the current user is not the root user, add sudo before the command and run as an administrator
After successful creation, use the following command to view the created mysql instance:
docker ps -a
Use navicat to test whether the database is started successfully:
Username and password were set to root when docker was created just now
Click the test connection, it shows that the test is successful, indicating that the mysql instance of docker has been started normally
Finally, a small expansion, my previous blog taught you how to use vagrant to create a Linux virtual machine, if you don’t understand, you can refer to my other blog
Ultra-detailed window10 system quickly builds a Linux mirroring environment
When docker is just installed, we have to add it when executing various commandssudo, run as an administrator, which is more troublesome, we can switch to the root user when deploying the application in the docker environment:
su root
The following will pop up to enter the password:
You can enter the root user password when creating the virtual machine. If it is a virtual machine created with vagrant, the root user password is vagrant
After execution, we enter the following command to view the current user:
whoami
You can find that the user at this time has switched to root, you don't need to add sudo when executing the command again.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
密码学的基础:X.690和对应的BER CER DER编码
"NetEase Internship" Weekly Diary (2)
Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided
【Unity入门计划】2D Game Kit:初步了解2D游戏组成
检查IP或端口是否被封
手写一个博客平台~第三天
A good book for newcomers to the workplace
[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree
【LeetCode每日一题】——103.二叉树的锯齿形层序遍历
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
随机推荐
2022-08-01 Install mysql monitoring tool phhMyAdmin
LeetCode Review Diary: 34. Find the first and last position of an element in a sorted array
Scheduled tasks for distributed applications in Golang
AOF rewrite
MySQL优化策略
Use baidu EasyDL implement factory workers smoking behavior recognition
2022-07-30 mysql8 executes slow SQL-Q17 analysis
使用DBeaver进行mysql数据备份与恢复
Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
Golang分布式应用之Redis
检查IP或端口是否被封
How to adjust the cross cursor too small, CAD dream drawing calculation skills
AWR analysis report questions for help: How can SQL be optimized from what aspects?
2022-07-30 mysql8执行慢SQL-Q17分析
记一个gorm初始化的坑
LeetCode 213. Robbery II (2022.08.01)
nacos startup error, the database has been configured, stand-alone startup
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings