sudo docker exec -it gogs_mysql bash
mysql -u root -p
use mysql;
# 创建gogs用户
CREATE USER 'gogs'@'%' IDENTIFIED BY '123456789';
# CREATE USER 'gogs'@'172.21.0.1' IDENTIFIED BY '123456789';
# 授权gogs用户可以操作gogs库下所有表
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'%' WITH GRANT OPTION;
# GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'172.21.0.1' WITH GRANT OPTION;
# 授权远程三方工具连接MySQL
ALTER USER 'gogs'@'%' IDENTIFIED WITH mysql_native_password BY '123456789';
# ALTER USER 'gogs'@'172.21.0.1' IDENTIFIED WITH mysql_native_password BY '123456789';
# 刷新授权
FLUSH PRIVILEGES;
# 创建gogs库
CREATE DATABASE `gogs` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';