#访问控制
# #登录mysql
Mysql-u root-p
# #查看所有用户
Select User from Mysql.user
# #创建用户
CREATE USER ' username ' @ ' host ' identified by ' password ';
# #删除用户
Note that you must explicitly give the hostname of the account
Drop user ' test ' @ ' localhost ';
# #重命名用户
Rename user ' test ' @ ' localhost ' to ' foo ' @ ' localhost ';
# #修改密码
Set password for ' test ' @ ' localhost ' =password (' hello ');
#权限管理
# #查看权限
Show grants for ' test ' @ ' localhost ';
# #授权
Grant Select (Cust_id,cust_name) on mysql_test.customers to ' zhangsan ' @ ' localhost ';--Grant in the database Mysql_ Test has SELECT permission on the table customers for columns cust_id and columns Cust_name
Grant SELECT, update on mysql_test.customers to ' liming ' @ ' localhost ' identified by ' 123 ';--Create a new user for liming, and grant it permission to have select and update on the table customers of the database Mysql_test
Grant all on mysql_test.* to ' zhangsan ' @ ' localhost ';--grant permission to perform all operations in the database Mysql_test
Grant create user on * . * to ' zhangsan ' @ ' localhost ';--grant the user Zhangsan already present in the system.
# #权限的转移
Grant Select,update on mysql_test.customers to ' Zhou ' @ ' localhost ' identified by ' 123 ' with grant option;
If the above with clause is followed by the
Max_queries_per_hour Count,
Max_updates_per_hour Count,
Max_connections_per_hour Count,
Max_user_connections Count
, the grant statement can be used to restrict permissions
Grant Delete on mysql_test.customers to ' zhangsan ' @ ' localhost ' with max_queries_per_hour 1;-- Permission to process only one DELETE statement per hour
# #权限的撤销
Revoke select on Mysql_test.customers from ' zhangsan ' @ ' localhost ';--Recycle user Zhangsan in database mysql_ Select permission on table customers of test
Transported from http://blog.csdn.net/ParanoidYang/article/details/61951265
MySQL Basic operation