2022-12-07
mysql创建全库只读用户命令
mysql创建只读用户命令,mysql建只读用户
版本mysql5.7 版本mysql8 OK
一行命令建用户加赋权官方已经弃用了,mysql5.7可以但warning,mysql8不行
GRANT SELECT ON *.* TO 'read_only'@'%' IDENTIFIED BY 'PAP@!111';
1.新建用户【readonly】全库只读
CREATE USER 'readonly'@'%' IDENTIFIED BY 'Password@@!!$$11';
GRANT SELECT ON *.* TO 'readonly'@'%';
FLUSH PRIVILEGES;
2.新建用户【readonly】在【db001库】单库只读
CREATE USER 'readonly'@'%' IDENTIFIED BY 'Password@@!!$$11';
GRANT SELECT ON db001.* TO 'readonly'@'%';
FLUSH PRIVILEGES;