当前位置:Gxlcms > 数据库问题 > Docker搭建MySQL数据库

Docker搭建MySQL数据库

时间:2021-07-01 10:21:17 帮助过:18人阅读

-eMYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

命令中显示我们使用的是Docker技术并创建一个名字为mysql的容器,然后在容器中把数据关联到本地的MySQL,并把MySQL的3306接口映射到外面的3308,同时为用户设置一个账户密码

2、进入镜像

docker exec -it mysql bash

3、连接mysql

执行命令: mysql -h127.0.0.1 -p
root@706629fa5ef0:/# mysql -h127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

 

Docker搭建MySQL数据库

标签:显示   unit   lib   pass   clear   mat   数据库   color   iat   

人气教程排行