docker安装mysql

1、docker下载镜像。

#我们查看一下docker.hup上的镜像。
[root@bfd-v7 ~]# docker search mysql
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                                                  MySQL is a widely used, open-source relation…   5578                [OK]                
mariadb                                                MariaDB is a community-developed fork of MyS…   1728                [OK]                
mysql/mysql-server                                     Optimized MySQL Server Docker images. Create383                                     [OK]
hypriot/rpi-mysql                                      RPi-compatible Docker Image with Mysql          77                                      
zabbix/zabbix-server-mysql                             Zabbix Server with MySQL database support       72                                      [OK]
centurylink/mysql                                      Image containing mysql. Optimized to be link…   58                                      [OK]
zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server wi…   40                                      [OK]
tutum/mysql                                            Base docker image to run a MySQL database se…   30                                      
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          24                                      [OK]
mysql/mysql-cluster                                    Experimental MySQL Cluster Docker images. Cr…   18                                      
schickling/mysql-backup-s3                             Backup MySQL to S3 (supports periodic backup…   16                                      [OK]
centos/mysql-57-centos7                                MySQL 5.7 SQL database server                   16                                      
linuxserver/mysql                                      A Mysql container, brought to you by LinuxSe…   13                                      
bitnami/mysql                                          Bitnami MySQL Docker Image                      11                                      [OK]
zabbix/zabbix-proxy-mysql                              Zabbix proxy with MySQL database support        10                                      [OK]
openshift/mysql-55-centos7                             DEPRECATED: A Centos7 based MySQL v5.5 image…   6                                       
centos/mysql-56-centos7                                MySQL 5.6 SQL database server                   6                                       
dsteinkopf/backup-all-mysql                                      

2、创建mysql的镜像,并运行。

[root@bfd-v7 ~]# docker run --name test-mysql -p 3308:3306  -e MYSQL_ROOT_PASSWORD=123456 -d mysql

#进入mysql的终端
[root@bfd-v7 ~]# docker exec -it some-mysql mysql -uroot -p123456

# 进入之后,要对用户进行授权,否则用navicat连接不上。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.12.5' IDENTIFIED BY '123456';

用navicat去远程连接容器中的mysql。
docker安装mysql_第1张图片

双击连接,头像变亮,表示mysql已经安装成功。
docker安装mysql_第2张图片

你可能感兴趣的:(docker+k8s)