docker部署mysql

2024-01-02 21:37:54

1.查找mysql镜像

[root@VM-4-5-centos ~]# docker search mysql
NAME                            DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                           MySQL is a widely used, open-source relation…   14739               [OK]                
mariadb                         MariaDB Server is a high performing open sou…   5624                [OK]                
phpmyadmin                      phpMyAdmin - A web interface for MySQL and M…   919                 [OK]                
percona                         Percona Server is a fork of the MySQL relati…   623                 [OK]                
bitnami/mysql                   Bitnami MySQL Docker Image                      105                                     [OK]
databack/mysql-backup           Back up mysql databases to... anywhere!         105                                     
ubuntu/mysql                    MySQL open source fast, stable, multi-thread…   55                                      
linuxserver/mysql-workbench                                                     54                                      
linuxserver/mysql               A Mysql container, brought to you by LinuxSe…   41                                      
rapidfort/mysql                 RapidFort optimized, hardened image for MySQL   25                                      
google/mysql                    MySQL server for Google Compute Engine          25                                      [OK]
rapidfort/mysql-official        RapidFort optimized, hardened image for MySQ…   9                                       
rapidfort/mysql8-ib             RapidFort optimized, hardened image for MySQ…   9                                       
bitnami/mysqld-exporter                                                         6                                       
drupalci/mysql-5.5              https://www.drupal.org/project/drupalci         3                                       [OK]
cimg/mysql                                                                      2                                       
datajoint/mysql                 MySQL image pre-configured to work smoothly …   2                                       [OK]
newrelic/mysql-plugin           New Relic Plugin for monitoring MySQL databa…   1                                       [OK]
vitess/mysqlctld                vitess/mysqlctld                                1                                       [OK]
eclipse/mysql                   Mysql 5.7, curl, rsync                          1                                       [OK]
mirantis/mysql                                                                  0                                       
bitnamicharts/mysql                                                             0                                       
elestio/mysql                   Mysql, verified and packaged by Elestio         0                                       
drupalci/mysql-5.7              https://www.drupal.org/project/drupalci         0                                       
hashicorp/mysql-portworx-demo                                                   0                                       

2.下载mysql镜像

docker pull mysql

3.验证镜像

在这里插入图片描述

4.启动mysql镜像

docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql

解释:
-p	端口映射【3306(主机端口):3306(容器端口)】
--name	容器名字(如果不指定,会随机生成一个名字)
-e	容器环境变量(指定账号密码,其中密码root/密码123456)
-d	后台运行(最后的mysql是镜像名字)

5.进入容器

docker exec -it mysql bash

6.进入mysql

注意:账号密码和启动镜像时设置的账号密码一致

bash-4.4# mysql -uroot -p
Enter password: 

格式:mysql -u账号 -p
密码不显示,输完直接回车即可

在这里插入图片描述

7.验证

在这里插入图片描述

文章来源:https://blog.csdn.net/weixin_47498728/article/details/135349396
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。