侧边栏壁纸
博主头像
张种恩的技术小栈博主等级

行动起来,活在当下

  • 累计撰写 748 篇文章
  • 累计创建 65 个标签
  • 累计收到 39 条评论

目 录CONTENT

文章目录

Docker安装连接MySql

zze
zze
2019-10-17 / 0 评论 / 0 点赞 / 461 阅读 / 1643 字

不定期更新相关视频,抖音点击左上角加号后扫一扫右方侧边栏二维码关注我~正在更新《Shell其实很简单》系列

1、拉取 mysql5.6 镜像文件:

[root@localhost ~]# docker pull mysql:5.6
Trying to pull repository docker.io/library/mysql ... 
5.6: Pulling from docker.io/library/mysql
27833a3ba0a5: Already exists 
864c283b3c4b: Already exists 
cea281b2278b: Already exists 
8f856c14f5af: Already exists 
9c4f38c23b6f: Already exists 
688342d0934f: Pull complete 
1f90d0188066: Pull complete 
6d31565f1a00: Pull complete 
12062e921a90: Pull complete 
066ae780ca9a: Pull complete 
f6eece737bcc: Pull complete 
Digest: sha256:de2913a0ec53d98ced6f6bd607f487b7ad8fe8d2a86e2128308ebf4be2f92667
Status: Downloaded newer image for docker.io/mysql:5.6

2、创建并运行一个 mysql5.6 的容器:

[root@localhost ~]# docker run --name mysql56 -e MYSQL_ROOT_PASSWORD=root -d -p 3306:3306 mysql:5.6 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
3f76e2bcd4e1762f40d9bd9dbd8aa5798c0e4f1035c1d518d05359fdcdcdfd19

3、通过 mysql 容器提供的客户端功能测试连接 mysql 容器:

[root@localhost ~]# docker run -it --link mysql56 --rm mysql:5.6 sh -c 'exec mysql -hmysql56 -uroot -proot'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.43 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>
0

评论区