Help us understand the problem. What is going on with this article?

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コマンドが失敗したらしい。

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.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした