回到顶部

阅读目录

docker-compose 安装部署 mysql

配置准备

docker 和 docker-compose 安装

http://xieboke.net/article/341/

创建 mysql主目录

mkdir /usr/local/mysql
cd /usr/local/mysql

创建 mysql 的子目录

mkdir conf data logs

conf 下 my.conf 配置文件

[client]
default-character-set=utf8mb4
 
[mysql]
default-character-set=utf8mb4
 
[mysqld]
skip-grant-tables
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error      = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address   = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
lower_case_table_names=1

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
 
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

max_connections = 1000

net_read_timeout=3600
net_write_timeout=3600

部署容器

创建 docker-compose.yml 文件

version: '3.1'
services:
  db:
    image: mysql:5.7 #mysql版本
    volumes:
      - ./data/db:/var/lib/mysql
      - ./conf/my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
    restart: always
    ports:
      - 13306:3306
    environment:
      MYSQL_ROOT_PASSWORD: 123abc #访问密码
      secure_file_priv:

启动容器

cd /usr/local/mysql
docker-compose up -d

 


^_^
请喝咖啡 ×

文章部分资料可能来源于网络,如有侵权请告知删除。谢谢!

前一篇: docker-compose 安装部署 redis
下一篇: 我的博客(卓越笔记)即将同步至腾讯云开发者社区,邀请大家一同入驻