如何安装mysql docker镜像

发布时间:2021-06-17 10:35:19 作者:小新
来源:亿速云 阅读:168

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

安装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 <CONTAINER ID> 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 <CONTAINER ID>

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

$ <winpty> docker run -it --rm mysql:<tag> --verbose --help

在windows下要加上 winpty

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

推荐阅读:
  1. Docker安装MySQL
  2. docker 安装mysql5.7

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql docker镜像

上一篇:PHP递归返回值时出现的问题怎么解决

下一篇:PHP截取中文字符出现乱码的解决方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》