linux docker 安装mysql,redis

mysql 安装

sudo docker pull mysql:5.7

创建实例并启动

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

参数说明
p 3306:3306:将容器的3306端口映射到主机的3306端口
-v /mydata/mysql/conf:/etc/mysql:将配置文件夹挂载到主机
-v /mydata/mys/xg/ar/log/mysql:将日志文件夹挂载到主机
-v /mydata/mysqldata/var/ib/mysql /:将配置文件夹挂载到主机
-e MYSQL_ROOT_ PASSWORD=root: 初始化root用户的密码

mysql修改配置

[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

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

上一篇:线性、对数指数拟合模型的建立和验证


下一篇:安装nginx,mysql,redis