1、创建只读账户:
提示:username和password为账号密码,自定义即可
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
创建一个账号为readyonly1,密码为readonly123的mysql账户
CREATE USER 'readyonly1'@'%' IDENTIFIED BY 'readonly123';
2、为只读账户分配权限
提示:username替换为新创建的只读用户:
GRANT SELECT ON *.* TO 'username'@'%' ;
示例
为readyonly1分配制度权限
GRANT SELECT ON *.* TO 'readyonly1'@'%' ;
3、刷新缓存:
FLUSH PRIVILEGES;