400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

如何安装mysqldocker镜像

这篇文章主要介绍了如何安装MySQL docker镜像,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联建站是一家专注于成都做网站、网站设计、外贸营销网站建设与策划设计,呈贡网站建设哪家好?创新互联建站做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:呈贡等地区。呈贡做网站价格咨询:18982081108

安装mysql docker镜像

搜索镜像

NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   8448                [OK]
mariadb                           MariaDB is a community-developed fork of MyS…   2907                [OK]

拉取镜像

 docker pull mysql:tag

tag mysql的镜像版本

启动mysql镜像

docker run 
   \ --name dmysql 
   \ -p 3307:3306 
   \ -e MYSQL_ROOT_PASSWORD=root 
   \ -d mysql:5.7 
   \ --character-set-server=utf8mb4
   \ --collation-server=utf8mb4_unicode_ci

查看Mysql进程

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
1094bc7f4078        mysql:5.7           "docker-entrypoint.s…"   2 months ago        Up 3 hours          33060/tcp, 0.0.0.0:3307->3306/tcp   dmysql

容器shell访问和查看MySQL日志

docker exec命令允许您运行命令进入一个docker容器。下面的命令行可以进入mysql容器的bash shell界面:

--- Linux
$ docker exec -it  mysql -uroot -p


--- Windows
$ docker exec -it 1094bc7f4078 /bin/bash
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
改为:

$ winpty docker exec -it 1094bc7f4078 mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 83
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

通过log参数查看容器的日志:

docker logs 

查看mysql镜像的所有参数列表

 docker run -it --rm mysql: --verbose --help

在windows下要加上 winpty

感谢你能够认真阅读完这篇文章,希望小编分享的“如何安装mysql docker镜像”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


文章题目:如何安装mysqldocker镜像
当前路径:http://mzwzsj.com/article/gojhos.html

其他资讯

让你的专属顾问为你服务