Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Docker install MySQL

Docker install MySQL

MySQL is the world's most popular open-source database. Thanks to its reliability, ease of use, and performance, MySQL has become the preferred database choice for web applications.

1. Check available MySQL versions

Visit the MySQL image repository address:https://hub.docker.com/_/mysql?tab=tags 。

You can use Sort by to view other versions of MySQL; the default is the latest version mysql:latest 。

You can also find other versions you want in the drop-down list:

In addition, we can use the docker search mysql command to view available versions:



$ docker search mysql

NAME                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED

mysql                    MySQL is a widely used, open-source relati...   2529      [OK]       

mysql/mysql-server       Optimized MySQL Server Docker images. Crea...   161                  [OK]

centurylink/mysql        Image containing mysql. Optimized to be li...   45                   [OK]

sameersbn/mysql                                                          36                   [OK]

google/mysql             MySQL server for Google Compute Engine          16                   [OK]

appcontainers/mysql      Centos/Debian Based Customizable MySQL Con...   8                    [OK]

marvambass/mysql         MySQL Server based on Ubuntu 14.04              6                    [OK]

drupaldocker/mysql       MySQL for Drupal                                2                    [OK]

azukiapp/mysql           Docker image to run MySQL by Azuki - http:...   2                    [OK]

...

2. Pull the MySQL image

Here we pull the official latest-version image:

$ docker pull mysql:latest

3. View local images

Use the following command to check whether mysql is installed:

$ docker images

In the figure above we can see that we have installed the mysql image of the latest version (latest).

4. Run the container

After installation, we can use the following command to run the mysql container:

$ docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql

Parameter Description:

5. Installation successful

Check whether the installation was successful with the docker ps command:

The local machine can access the MySQL service with root and the password 123456.