Mysql和redis的安装
一、mysql的安装
1.拉取镜像
docker pull mysql:5.7
2.启动容器
docker run -p 3306:3306 --name mysql -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
3.修改配置文件
vi /mydata/mysql/conf/my.cnf [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
- 重启
docker restart mysql
- 进入容器
docker exec -it mysql /bin/bash
- 查看步骤三修改的文件是否成功
cat /etc/mysql/my.cnf
二.安装redis
- 下载镜像
docker pull redis
- 配置文件
mkdir -p /mydata/redis/conf touch /mydata/redis/conf/redis.conf
- 启动容器
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
- 运行客户端
docker exec -it redis redis-cli
- 开启aof持久化
vi /mydata/redis/conf/redis.conf #添加如下内容 appendonly yes
- 重启redis
docker restart redis
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11