Steps to install mysql using docker and set password (under Linux system)

The premise is that docker has been installed in the Linux system. If it is not installed, please refer to the following website:
https://blog.csdn.net/qq_2662385590/article/details/105665053?utm_source=app
, and then perform the following steps:

  1. You can use the docker search mysql command to check the available versions:
    Insert picture description here
    2. To pull the MySQL image, use the command: docker pull mysql
    (this is to pull the latest version of the mysql image, if necessary, you can add the version number after mysql, Pull the corresponding mysql version. For example: docker pull mysql: 5.6, etc.)
    Insert picture description here
  2. To check whether the image is successfully pulled, use the command: docker images
    Insert picture description here
  3. Use the following command to run the mysql container:
    docker run -itd --name mysql01 -p 3306:3306
    -e MYSQL_ROOT_PASSWORD=123456 mysql

-p 3306:3306: Map port 3306 of the container service to port 3306 of the host. The external host can directly access the MySQL service through the host ip:3306.
MYSQL_ROOT_PASSWORD=123456: Set the password of the root user of the MySQL service.
--Name: Give the container a name and name it yourself.

5. Check whether the installation is successful through the docker ps command:
Insert picture description here
then you can access the MySQL service through the root user and password: 123456.

Guess you like

Origin blog.csdn.net/qq_2662385590/article/details/105843329