In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Get mysql image
Docker pull mysql:5.6
Note: mysql5.6 is obtained here because mysql5.7 may report an error when it starts in centos7
two。 View the list of images
Docker images
3. Start mysql Mirror
Docker run-itd-P mysql:5.6 bash
Where docker run is the command to start the container; I is an interactive operation, t is a terminal, and d refers to running in the background
-P refers to generating a random port locally to map port 3306 of mysql, mysql refers to running mysql image, and bash refers to creating an interactive shell.
4. View docker images that are already running
Docker ps-a
You can see from the figure that the port 3306 of the mysql image is bound to the local port 32769, so if you want to access the mysql database in docker in the local area network, you need to use the server IP:32769 to access it.
5. Connect to a mysql image
Docker exec-it relaxed_hodgkin bash
Docker exec is the connection command of docker image, which is similar to the command of ssh. Relaxed_hodgkin is the name of the image. Each time the image starts, it must have a name, which can be specified manually or generated by itself.
After the connection is successful, as shown in the following figure, it has been entered into the docker mysql image
6. Check the startup status of mysql. As shown in the figure above, mysql is not started.
Service mysql status
7.mysql is not started. You can start it with the following command, as shown in the figure.
Service mysql start
8. Enter mysql to verify that mysql starts successfully
At this point, the mysql in docker has been started successfully.
9. How do I use root to connect to this mysql externally? For security, you first need to set the password for the root account, as follows
Update user set authentication_string = password ('root') where user =' root'
The following error will be reported at this time
Because the database is not selected, to execute the following sentence before the above command, you can change the password of root to root.
Use mysql
10. Because the root execution in mysql is bound to localhost, root needs to be authorized
GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' root' WITH GRANT OPTION
11. Finally, test the mysql connection using SQLyog, as follows
The connection is successful, indicating that the mysql in docker can be used in the LAN.
This is the end of this article on the use of mysql database in docker to achieve local area network access. For more information about docker's operation of mysql database, please search the previous articles or continue to browse the relevant articles below. I hope you will support me in the future!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.