Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
250
Help us understand the problem. What is going on with this article?
@PallCreaker

MySQL の権限のコマンドまとめ。

More than 5 years have passed since last update.

まずどのユーザーがいるか知りたい。

SELECT user,host,password FROM mysql.user;

個々のユーザーの権限はなにか知りたい。

SHOW GRANTS FOR root@'localhost';

いわゆる何でもできる管理者用ユーザ

GRANT ALL ON *.* TO adminuser@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

※MySQLにはGRANT権限というものがあります。GRANT権限とは、他のユーザに対して権限を付与することができる権限のことです。当然のことながらGRANT権限は通常管理者用ユーザにか付与しません。

IP制限

GRANT ALL ON *.* TO adminuser@'172.16.0.0/255.255.255.0' IDENTIFIED BY 'password' WITH GRANT OPTION;

全てのデータベースにアクセスできる一般ユーザ(WITH GRANT OPTIONがないのに注目)

GRANT ALL ON *.* TO testuser@'%' IDENTIFIED BY 'password';

特定のデータベースにアクセスできる一般ユーザ

GRANT ALL ON testdatabase.* TO testuser@'%' IDENTIFIED BY 'password';

init_connect
らへんは、

SELECT,INSERT,UPDATE,DELETEしかできない一般ユーザ

GRANT SELECT,INSERT,UPDATE,DELETE ON testdatabase.* TO testuser@'%' IDENTIFIED BY 'password';

手動で権限テーブルをリロードする

FLUSH PRIVILEGES;

参考:init_connectコマンドが失敗したらしい。

250
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
250
Help us understand the problem. What is going on with this article?