本地账号
create user ‘tang’@’localhost’ identified by ‘123’; # mysql -utang -p123
远程账号
create user ‘tang’@’192.168.1.1’ identified by ‘123’; # mysql -utang -p123 -h服务端IP
create user ‘tang’@’192.168.1.%’ identified by ‘123’; # mysql -utang -p123 -h服务端IP (%代表任意)
create user ‘tang’@’%’ identified by ‘123’; # mysql -utang -p123 -h服务端IP
user:.
db:tang1.*
tables_priv:tang1.student
columns_priv:id,name
grant all on . to ‘tang’@’localhost’; 授权user所有的权限
grant select on . to ‘tang’@’localhost’; 只授权user查询的权限
revoke select on . to ‘tang’@’localhost’; 取消user的查询权限
grant select on tang1.* to ‘tang’@’localhost’;
revoke select on tang1.* to ‘tang’@’localhost’;
grant select on tang1.student to ‘tang’@’localhost’;
revoke select on tang1.student to ‘tang’@’localhost’;
grant select(id,name),update(name) on tang1.student to ‘tang’@’localhost’;
revoke select(id,name),update(name) on tang1.student to ‘tang’@’localhost’;