Mysql和redis的安裝

2022-08-17 12:09:26 字數 1596 閱讀 1247

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

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

#新增如下內容

重啟redis

docker restart redis

docker中安裝mysql和Redis

此處的映象倉庫為阿里雲映象倉庫,配置詳見阿里雲映象加速配置 docker pull mysql 5.7sudo docker run p 3306 3306 name mysql v mydata mysql log var log mysql v mydata mysql data var lib...

centos下安裝Mysql和redis資料庫

mysql的安裝 先安裝wget 命令行為 yum install wget 1 前往使用者根目錄 cd wget 3 安裝mysql57 yum y install mysql57 community release el7 10.noarch.rpm yum y install mysql co...

docker安裝mysql和redis環境

sudo yum remove docker docker client docker client latest docker common docker latest docker latest logrotate docker logrotate docker enginesudo yum i...