你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

Docker 中部署 MySQL 8.0.18

2021/12/29 2:56:08

Docker 中部署 MySQL 8.0.18

docker pull mysql:8.0.18
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.18

Linux中进入MySQL

  • 直接进入会报 -bash: mysql: command not found 错误。
  • 正确进入方式:
[root@localhost ~]# docker exec -it mysql-test /bin/bash	# mysql-test为容器名,使用docker ps查看
root@43deabdb3d79:/# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.18 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> 

远程连接

  • 直接使用 mysql -h IP -u root 连接即可。
  • 推荐使用 Navicat 。