001 docker-compose mysql

  1. docker-compose.yml
version: '3.1'
services:
  mysql:
    image: mysql:5.7
    restart: always
    container_name: mysql
    privileged: true
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: liubo@2021
    command:
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
      --max_allowed_packet=256M
    ports:
      - 3306:3306
    volumes:
      - /opt/mysql/data:/var/lib/mysql
      - /opt/mysql/config/my.cnf:/etc/mysql/my.cnf
      - /opt/mysql/log:/var/log/mysql
  1. my.conf
vim /opt/mysql/config/my.conf
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
max_connections=2048
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL

# Custom config should go here
!includedir /etc/mysql/conf.d/


你可能感兴趣的:(001 docker-compose mysql)