# mysql容器
1.运行mysql容器:
```bash
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/conf/:/etc/mysql/ \
-v /mydata/mysql/data/:/var/lib/mysql/ \
-v /mydata/mysql/log/:/var/log/mysql/ \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7
```
2.mysql配置文件
```bash
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
```
里面的中括号为英文
# redis容器
1.运行redis容器
由于/etc/redis目录下没有redis.conf文件,所以要先创建redis.conf文件
```bash
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
```
然后再运行容器
```bash
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
```