顯示使用者清單:
mysql > select * from mysql.user;
會顯示全部列表,但不容易看得清楚。
只顯示 mysql 這個資料庫中 user 資料表的 Host 及 User 共2個欄位
只顯示 mysql 這個資料庫中 user 資料表的 Host 及 User 共2個欄位
mysql > select Host, User from mysql.user;
新增使用者:
mysql > create user 'UserName'@'Host' identified by 'Password';
給予某些權限 OPTION 如 SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
TARGET 為指定資料庫
TARGET 為指定資料庫
mysql > grant OPTION on TARGET to USER;
刪除使用者:
mysql > drop user 'UserName'@'Host';
新增使用者:
mysql > create user 'marry'@'localhost' identified by 'abcd2345';
mysql > create user 'marry'@'%' identified by 'abcd2345';
mysql > create user 'marry'@'%' identified by 'abcd2345';
其中要注意的是使用者名稱跟指定來源主機的字串需要各別加單引號。
給予權限:
mysql > grant all on *.* to 'marry'@'localhost';
這樣 marry 對整個資料庫的所有資料表都擁有全部的權利
mysql > grant select,insert on myFirstDB.* to 'marry'@'localhost';
marry 只擁有對 myFirstDB 這個資料檔[的所有表格]的查詢及新增權利。
沒有留言:
張貼留言