mysqlユーザーの作成とユーザーへの権限の付与

652 ワード

mysqlユーザーに関する情報はmysql.userテーブル
1.クエリー
use mysql;

select host,user,password from user;  

2.sportsnoteというユーザーを作成する
create user sportsnote identified by 'sportsnote'; 

3.データベースsportsnoteのselect権限をsportsnoteユーザーに付与する.
grant select on sportsnote.* to sportsnote;  

この場合、sportsnoteユーザーはデータベースsportsnoteに対してクエリーの権限のみを使用し、他の権限はありません.
4.すべての権限をユーザーに付与
grant all on sportsnote.* to sportsnote @'%'; 

この場合、すべてのホスト上のsportsnoteユーザーは、データベースsportsnoteの下のすべてのテーブルにすべての権限を有します.
注意:上記の例のユーザー名とデータベース名はたまたま一致しました.わざとじゃないよ!