当前位置:网站首页>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
边栏推荐
- 用位运算为你的程序加速
- LeetCode刷题日记:153、寻找旋转排序数组中的最小值
- Effects of Scraping and Aggregation
- LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
- Power button 1374. Generate each character string is an odd number
- Unable to log in to the Westward Journey
- 使用DBeaver进行mysql数据备份与恢复
- AOF重写
- Simple example of libcurl accessing url saved as file
- AI target segmentation capability for fast video cutout without green screen
猜你喜欢

AOF rewrite

Handwritten Blog Platform ~ Day Two

Unable to log in to the Westward Journey

Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided

nacos startup error, the database has been configured, stand-alone startup

用位运算为你的程序加速

Hash collisions and consistent hashing

Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas

typescript33 - high-level overview of typescript

The ultra-large-scale industrial practical semantic segmentation dataset PSSL and pre-training model are open source!
随机推荐
AOF rewrite
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
LeetCode Brushing Diary: 74. Searching 2D Matrix
2022河南青训联赛第(三)场
MySQL - CRUD operations
A good book for newcomers to the workplace
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
Constructor instance method inheritance of typescript37-class (extends)
Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记
PHP live source code to achieve simple barrage effect related code
60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
LeetCode刷题日记:153、寻找旋转排序数组中的最小值
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline
编码经验之谈
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
CodeTon Round 2 D. Magical Array 规律
拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
Analysis of the status quo of digital transformation of manufacturing enterprises
LeetCode brush diary: LCP 03. Machine's adventure
NIO‘s Sword(牛客多校赛)