Mysql 創建賬戶和設置權限

查看現有的用戶

select host,user,authentication_string from mysql.user;

創建用戶

create user '用戶名'@'host' identified by "密碼";

host="localhost"爲本地登錄用戶
host="ip"爲ip地址登錄
host="%",爲外網ip登錄

刪除用戶

drop user 'username'@'host';

權限設置

	//授予用戶通過外網IP對於該數據庫的全部權限
  grant all privileges on `test`.* to 'test'@'%' ;
  
	/*授予用戶在本地服務器對該數據庫的全部權限*/	
  grant all privileges on `test`.* to 'test'@'localhost';   

   grant select on test.* to 'user1'@'localhost';  /*給予查詢權限*/

   grant insert on test.* to 'user1'@'localhost'; /*添加插入權限*/

   grant delete on test.* to 'user1'@'localhost'; /*添加刪除權限*/

   grant update on test.* to 'user1'@'localhost'; /*添加權限*/

  flush privileges; /*刷新權限*/

查看權限

 show grants; //全部
 show grants for 'jack'@'%'; //指定用戶

刪除權限

revoke privileges on databasename.tablename from 'username'@'host';

revoke delete on test.* from 'jack'@'localhost';

https://www.cnblogs.com/wuxunyan/p/9095016.html

grant 權限 on 數據庫對象 to 用戶

https://www.cnblogs.com/yunfeioliver/p/7887676.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章