mysqlユーザーと権限の割り当ての新規削除

1859 ワード

1.新規ユーザー
mysql>insert into mysql.user(Host,User,Password) values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;

 
2.ユーザーパスワードの変更
mysql>update mysql.user set password=password('new password') where User="lionbule" and Host="localhost";
mysql>flush privileges;

3.ユーザーの削除
mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost";
mysql>flush privileges;

 
4.権限の割当て
    4.1.牙列缺损
grant権限onデータベース.*toユーザー名@'ログインホスト'identified by'パスワード'
  :
        , ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
   :
     *.*                             
     test.*                  test     
     test.test_table    test  test_table      
   :
     mysql   
    :
         mysql server    ip
     '%'    ip
     'localhost'     
     '192.168.10.2'   IP
  :
               

 
4.2例
mysql>grant all  on test.* to lionbule@'%' identified by 'hello1234';
mysql>flush privileges;

新しいパスワードが「hello 234」のユーザーlionbuleはtestライブラリに対してすべての操作権限を持ち、lionbuleユーザーのログインIPを制限しない.    
 
4.3注意事項
grantは、insert、update実行機能と同様に、ユーザの情報の一部を上書きする.
 
参照先:
http://dev.mysql.com/doc/refman/5.6/en/grant.html
http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html