mysql 創建使用者+權限

1. 新增使用者:
  mysql > create user 'UserName'@'Host' identified by 'Password';

2. 給予權限:
  mysql > grant OPTION on TARGET to USER;

3. 刪除使用者:
  mysql > drop user OPTION 'UserName'@'Host';

註:
 1. UserName 為使用者名稱,例如 root , joey , jackey ...,請注意,要加單引號(')
 2. Password 為密碼,請注意,要加單引號(')

Example:
 1. 新增使用者:
   mysql > create user 'joey'@'localhost' identified by 'abcd2345';
   mysql > create user 'joey'@'%' identified by 'abcd2345';

 2. 給予權限:
   mysql > grant all on *.* to 'joey'@'localhost';
     (注意:joey 對整個資料庫的所有資料表都擁有全部的權利)

   mysql > grant select,insert on myFirstDB.* to 'joey'@'localhost';
     (joey 只擁有對 myFirstDB 這個資料檔[的所有表格]的查詢及新增權利)
     (權利:SELECT,INSERT,UPDATE,DELETE,CREATE,DROP)

 3. 刪除使用者:
   mysql > drop user 'joey'@'localhost';

0 意見:

張貼留言