Docker搭建MySQL数据库
1、docker 可以执行如下命令一步搭建MySQL数据库:
docker run --name mysql -v $PWD/mysql:/var/lib/mysql -p3306:3308 -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
:/# 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)
相关推荐
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16
bianruifeng 2020-11-16