MySQLユーザの権限管理
全ユーザ表示
> select user,host from mysql.user;
ユーザ作成
> create user foo@localhost identified by 'password';
ユーザの権限表示
> show grants for foo@localhost;
+-----------------------------------------+
| Grants for foo@localhost |
+-----------------------------------------+
| GRANT USAGE ON *.* TO 'foo'@'localhost' |
+-----------------------------------------+
1 row in set (0.00 sec)
グローバルに全権限付与
> grant all on *.* to foo@localhost;
全権限がある状態
> show grants for foo@localhost;
+--------------------------------------------------+
| Grants for foo@localhost |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'foo'@'localhost' |
+--------------------------------------------------+
1 row in set (0.00 sec)
権限は以下のような区分で設定ができる
区分
- グローバル
- データベースごと
- テーブルごと
- カラムごと
https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html