目录
mysql -h 127.0.0.1 -uroot -p
输入密码直接回车即可登录
use mysql;
CREATE USER 'aaa'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'aaa'@'%';
使用以下命令刷新MySQL权限以使更改生效
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'aaa'@'ip_address' IDENTIFIED BY 'password';
- GRANT ALL PRIVILEGES ON database_name.* TO 'aaa'@'host';
-
- FLUSH PRIVILEGES;
现在,限制了用户只能访问特定的数据库。
- GRANT SELECT, INSERT, DELETE ON database_name.table_name TO 'aaa'@'host';
-
- FLUSH PRIVILEGES;
现在,用户只能访问特定数据库中的特定表。
REVOKE ALL PRIVILEGES ON database_name.* FROM 'aaa'@'%';
SHOW GRANTS FOR 'aaa'@'%';
更全用户权限后记得刷新权限
FLUSH PRIVILEGES;