【Mysql】Docker方式安装mysql5.7版本,并进行数据导入
【代码】Docker方式安装mysql5.7版本。
·
1.执行命令如下
- 映射配置文件
- 映射数据
- 设置忽略大小写
docker run -d -p 13306:3306 -v /home/hfg/Soft/mysql/conf:/etc/mysql/conf.d -v \
/home/hfg/Soft/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=r0ot \
--name mysql mysql:5.7 --lower_case_table_names=1
2. 如下就是启动成功
3.数据导入
## 查看当前容器
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
344088daee8a mysql:5.7 "docker-entrypoint.s…" 15 hours ago Up 6 minutes 33060/tcp, 0.0.0.0:13306->3306/tcp, :::13306->3306/tcp mysql
[root@localhost ~]#
[root@localhost ~]#
## 进入容器
[root@localhost ~]# docker exec -it 344 bash
root@344088daee8a:/# ls
bin boot dev docker-entrypoint-initdb.d entrypoint.sh etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@344088daee8a:/# cd /var/lib/mysql
## 将数据拷贝到 /var/lib/mysql,并进行登录
root@344088daee8a:/var/lib/mysql# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36 MySQL Community Server (GPL)
## 创建数据库
mysql> create dabase xxx;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dabase xxx' at line 1
mysql> create database xxx;
Query OK, 1 row affected (0.00 sec)
mysql> ues xxx;
## 开始进行导入
mysql> source /var/lib/mysql/mysqlxxx_20220207.0924.sql
更多推荐
已为社区贡献4条内容
所有评论(0)