1.创建用户
create user 'root'@'%' identified by 'root';
2.授权
语法:grant 权限名 on 数据库.数据表 to ‘用户名’@‘访问权限’ with grant option;
示例1:给root用户授予所有库表的全部权限
grant all privileges on *.* to 'root'@'%' with grant option;
示例2:给root用户授予特定库的所有表的写权限
grant select,insert,update on test_db_one.* to 'root'@'%' with grant option;
说明:
(1):all privileges 所有权限
(2):这里的 all privileges 可以替换为 select, update, delete, insert, drop, create等
(3):. 左右星号分别为数据库和数据表
(4):‘’@‘’ 艾特符号左右分别代表用户名和访问权限,%为不限制远程IP访问
(5):with grant option 表示该用户可以给其他用户赋权,但是不能超过该用户的权限
3.刷新权限(每次权限变更都要刷新特权)
flush privileges;