CREATE USER 'read_only_user'@'ip' IDENTIFIED BY 'password';
read_only_user就是用户名,随便起,ip就是允许连接到这个数据库的ip,当然如果不限制ip,那就写成 %,最后的password就是连接密码了。
GRANT SELECT ON *.* TO 'read_only_user'@'ip' WITH GRANT OPTION;
REVOKE all privileges ON *.* FROM 'read_only_user'@'ip';
flush privileges;
SHOW GRANTS FOR read_only_user;