mysql
docker pull mysql
# MYSQL_ROOT_PASSWORD root密码
/etc/mysql/my.cnf # 配置文件
/var/lib/mysql # 存储挂载
version: '3'
services:
mysql:
image: mysql:5.7 # 一定要写清楚版本号,不同版本之间会出现不兼容
privileged: true
restart: always # 自动重启
ports:
- 33309:3306
volumes:
- ./mysql:/var/lib/mysql # 文件存储
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=123456 # root密码
log-error=/var/lib/mysql/mysqld.log
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
explicit_defaults_for_timestamp=true
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
log_timestamps = SYSTEM # 同步系统时间
connect_timeout = 60 # 连接超时
interactive_timeout = 120 # 交互超时
max_allowed_packet=20M # 最大允许数据包
max_connections = 2000
log_bin=mysql-bin
binlog-format=row
expire_logs_days=3
max_binlog_size=100m
binlog_cache_size=10m
max_binlog_cache_size=512m
binlog_stmt_cache_size=100m
max_binlog_stmt_cache_size=100m
server_id=1
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
use mysql;
# 创建用户
CREATE USER 'join_web_user'@'%' IDENTIFIED BY 'jo!n141421';
# 查看用户
select * from user
# 授权指定库和表
# 语法 GRANT [privileges] on [[databasename].[tablename] to ‘user’@‘host’
# privileges SELECT,INSERT,UPDATE,ALL
# databasename.tablename 如果全部授权则填写为*或者*.*,databasename.*
# ‘user’@‘host’ 登录用户名
GRANT all privileges ON *.* TO 'join_web_user'@'%'
# 刷新权限
flush privileges;
# 删除权限
# 语法 REVOKE [privileges] ON [[databasename].[tablename] from 'join_web_user'@'%'
# 其他操作参数的使用与授权一致
REVOKE all ON *.* from 'join_web_user'@'%'
# 删除用户
DROP USER 'join_web_user'@'%';