当前位置:网站首页>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 mysqlSpecify 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.7Here 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 rootThe 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
边栏推荐
- The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
- [ORB_SLAM2] SetPose, UpdatePoseMatrices
- 编码经验之谈
- nacos启动报错,已配置数据库,单机启动
- PHP uses PHPRedis and Predis
- 力扣(LeetCode)213. 打家劫舍 II(2022.08.01)
- How to adjust the cross cursor too small, CAD dream drawing calculation skills
- 2022-08-01 反思
- AntPathMatcher使用
- Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
猜你喜欢

【 wheeled odometer 】

nacos启动报错,已配置数据库,单机启动

垃圾回收器CMS和G1

AI目标分割能力,无需绿幕即可实现快速视频抠图

用位运算为你的程序加速
![[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline](/img/08/d693c7e2fff8343b55ff3c1f9317c6.jpg)
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline

MySQL优化策略

The principle and code implementation of intelligent follower robot in the actual combat of innovative projects

密码学的基础:X.690和对应的BER CER DER编码

BI-SQL丨WHILE
随机推荐
『网易实习』周记(一)
MySQL optimization strategy
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline
Analysis of volatile principle
『网易实习』周记(二)
2022 Henan Youth Training League Game (3)
『网易实习』周记(三)
Centos7 安装postgresql并开启远程访问
AWR分析报告问题求助:SQL如何可以从哪几个方面优化?
使用docker安装mysql
AOF重写
Service discovery of kubernetes
Ask God to answer, how should this kind of sql be written?
AOF rewrite
【web】理解 Cookie 和 Session 机制
Coding Experience Talk
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
乱七八糟的网站
¶ Backtop back to the top is not effective
【LeetCode每日一题】——704.二分查找