大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇内容介绍了“docker安装MySQL5.7的过程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
创新互联公司是一家专注于成都网站建设、网站建设与策划设计,东营区网站建设哪家好?创新互联公司做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:东营区等地区。东营区做网站价格咨询:13518219792
查找Docker Hub上的mysql镜像:
[root@docker01 ~]# docker search mysql
以下是内容输出
NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 6498 [OK] mariadb MariaDB is a community-developed fork of MyS… 2049 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 475 [OK] percona Percona Server is a fork of the MySQL relati… 344 [OK] zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 106 [OK] hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 88
|
[root@docker01~]# docker pull mysql:5.7
5.7: Pulling from library/mysql 683abbb4ea60: Downloading [===============================================> ] 21.16MB/22.5MB 0550d17aeefa: Download complete 7e26605ddd77: Download complete 9882737bd15f: Download complete 999c06ab75f6: Download complete c71d695f9937: Download complete c38f847c1491: Download complete 74f9c61f40bf: Download complete 30b252a90a12: Downloading [======> ] 11.2MB/83.46MB 9f92ebb7da55: Download complete 90303981d276: Download complete
|
[root@docker01 mysql]# docker run -p3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/mysql_data-e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
d98e86d6b54fae37a1aff3b9f0fb04d5146936b4ce5f2b2c059043035d1b96e9
[root@docker01 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d98e86d6b54f mysql:5.7 "docker-entrypoint.s…" About a minute ago Up About aminute 0.0.0.0:3306->3306/tcp mymysql
登录docker容器:
登录docker容器的几种方法中,下面这种最常用,这种方法可以保证在退出的时候不会退出容器。
[root@docker01 mysql]# docker exec-it d98e /bin/bash
root@d98e86d6b54f:/#
在宿主机直接登录mysql
[root@docker01 mysql]# mysql -uroot-p123456 -h 172.17.0.1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22 MySQLCommunity Server (GPL)
Copyright (c) 2000, 2017, Oracle,MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type'\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
这种方式是最简单的安装方式,很多时候,我们把容器作为一个虚拟机来折腾,反而要比这样安装好玩一些。
“docker安装mysql5.7的过程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!