標籤:mysql sele connect 修改 highlight grant sql cal 授權
#存取控制
##登入mysql
mysql -u root -p
##查看所有使用者
select user from mysql.user
##建立使用者
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
##刪除使用者
注意必須明確給出該帳號的主機名稱
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‘;--授予在資料庫mysql_test的表customers上擁有對列cust_id和列cust_name的select許可權
grant select ,update on mysql_test.customers to ‘liming‘@‘localhost‘identified by‘123‘;--建立一個使用者為liming,並授予其在資料庫mysql_test的表customers上擁有select和update的許可權
grant all on mysql_test.* to‘zhangsan‘@‘localhost‘;--授予可以在資料庫mysql_test中執行所有操作的許可權
grant create user on *.* to‘zhangsan‘@‘localhost‘;--授予系統中已存在使用者zhangsan擁有建立使用者的許可權
##許可權的轉移
grant select,update on mysql_test.customers to‘zhou‘@‘localhost‘identified by‘123‘ with grant option;
如果上面with子句後面跟的是
max_queries_per_hour count、
max_updates_per_hour count、
max_connections_per_hour count、
max_user_connections count
中的某一項,則該grant語句可用於限制許可權
grant delete on mysql_test.customers to ‘zhangsan‘@‘localhost‘ with max_queries_per_hour 1;--每小時只能處理一條delete語句的許可權
##許可權的撤銷
revoke select on mysql_test.customers from‘zhangsan‘@‘localhost‘;--回收使用者zhangsan在資料庫mysql_test的表customers上的select許可權
搬運自http://blog.csdn.net/ParanoidYang/article/details/61951265
mysql基本操作