# 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] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql # 不使用密码 # skip-grant-tables # 设置FILE权限,限制mysqld导入/导出 secure-file-priv=NULL # Custom config should go here !includedir /etc/mysql/conf.d/ # 注意,以下为额外配置按需求进行增删, 20211130 # 设置权限插件 default_authentication_plugin=mysql_native_password # 设置最大连接数 max_connections=200 # 允许连接失败的次数,防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 创建新表示将使用默认的存储引擎 default-storage-engine=INNODB # 服务端默认使用字符集默认为utf-8 character-set-server=utf8 # 设置端口 port=3306
壹.运行
启动容器
在mysql文件夹运行
1
docker-compose up
或者后台启动
1
docker-compose up -d
查看运行结果
1 2 3 4
docker-compose ps Name Command State Ports -------------------------------------------------------------------------------------------------------------- mysql_compose docker-entrypoint.sh mysql ... Up 0.0.0.0:13306->3306/tcp,:::13306->3306/tcp, 33060/tcp
关闭并删除容器
1
docker-compose down
贰.验证
本地(Local)验证
1 2 3
docker exec -it mysql_compose /bin/bash mysql -uroot -p Enter password:
或者
1
docker exec -it mysql_compose mysql -uroot -P13306 -p123456