docker-compose 安装
version: '3.8'
services:
mariadb:
image: mariadb:latest
container_name: mariadb
environment:
MYSQL_ROOT_PASSWORD: passwd
TIME_ZONE: Asia/Shanghai
ports:
- "8000:3306"
volumes:
- ./data:/var/lib/mysql
networks:
- mariadb
networks:
mariadb:
name: mariadb
其他容器应用mariadb桥接网络
networks:
mariadb:
external: true
创建用户
CREATE USER 'user1'@'%' IDENTIFIED BY 'your_password';
创建数据库
CREATE DATABASE db1;
授予权限
GRANT ALL PRIVILEGES ON db1.* TO 'user1'@'%';
查看用户权限
SHOW GRANTS FOR 'username'@'%';
查看所有用户
SELECT User, Host FROM mysql.user;
应用权限
FLUSH PRIVILEGES;
发表回复