没有合适的资源?快使用搜索试试~ 我知道了~
mysql5.6镜像使用-自定义配置文件-重点4
需积分: 5 0 下载量 130 浏览量
2023-07-21
22:43:57
上传
评论
收藏 78KB DOCX 举报
温馨提示
mysql5.6镜像使用-自定义配置文件-重点4
资源推荐
资源详情
资源评论
docker 拉取 mysql5.6 镜像,并 run 一个容器,使用 mysql 服务
在宿主机:192.168.224.130 上安装 docker,再下载 mysql5.6 镜像后运行 mysql5.6 容器(和宿主机端口映射和目录映射),通过宿主机访问容器 mysql
数据
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
[root@localhost ~]# docker search mysql:5.6
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 7939 [OK]
mariadb MariaDB is a community-developed fork of MyS… 2653 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 598
…………
[root@localhost ~]# docker pull mysql:5.6
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.6 b3983abaa3fe 10 days ago 302 MB
1)先随便运行一个 mysql5.6 容器测试一下,供分析一下里面的配置文件、数据目录、日志目录等位置
[root@localhost ~]# docker run -p 3306:3306 --name mysql -v /tmp:/tmp -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
136c6ff4b13b mysql:5.6 "docker-entrypoint..." 5 seconds ago Up 1 second 0.0.0.0:3306->3306/tcp mysql
[root@localhost ~]# docker exec -it mysql /bin/bash
root@136c6ff4b13b:/# mysql -uroot -p123456
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
mysql> create database ku;
mysql> use ku;
mysql> create table biao (name varchar(10),age int(2));
mysql> insert into biao values ("shi",28);
mysql> select * from biao;
+------+------+
| name | age |
+------+------+
| shi | 28 |
+------+------+
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
mysql> quit
root@136c6ff4b13b:/# exit
[root@localhost ~]# docker exec -it mysql ls / #查看容器里/下目录
bin docker-entrypoint-initdb.d home media proc sbin tmp
boot entrypoint.sh lib mnt root srv usr
dev etc lib64 opt run sys var
[root@localhost ~]# docker exec -it mysql ls /var/lib/mysql #查看容器里数据目录
auto.cnf ib_logfile0 ib_logfile1 ibdata1 ku mysql performance_schema
[root@localhost ~]# docker exec -it mysql ls /etc/mysql #查看容器里配置文件目录
conf.d my.cnf my.cnf.fallback mysql.cnf mysql.conf.d
[root@localhost ~]# docker exec -it mysql cat /etc/mysql/my.cnf |grep -v "#"
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[root@localhost ~]# docker exec -it mysql ls /etc/mysql/conf.d
docker.cnf mysql.cnf mysqldump.cnf
[root@localhost ~]# docker exec -it mysql ls /etc/mysql/mysql.conf.d
mysqld.cnf
[root@localhost ~]# docker exec -it mysql cat /etc/mysql/mysql.conf.d/mysqld.cnf |grep -v "#"
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
symbolic-links=0
[root@localhost ~]# docker exec -it mysql cat /etc/mysql/conf.d/mysql.cnf
[mysql]
分析结果:
a)容器中主配置文件位置:/etc/mysql/my.cnf,里面啥都没有,只是 include 了一个目录路径,供存放配置文件和修改配置文件使用。
b)容器里引用的配置文件目录位置:/etc/mysql/conf.d/和/etc/mysql/mysql.conf.d/
c)容器里服务端 mysqld.conf 文件位置:/etc/mysql/mysql.conf.d/mysqld.cnf
d)容器里客户端 mysql.conf 文件位置:/etc/mysql/conf.d/mysql.cnf
e)容器里的目录位置:默认没有,可以映射一个/logs,供以后查看日志使用。
f)容器里的数据文件位置:/var/lib/mysql
剩余9页未读,继续阅读
资源评论
运维实战课程
- 粉丝: 1578
- 资源: 410
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功