1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MySQL】データベースにユーザーを作成・権限付与する

Posted at

MySQLのDBでユーザーを作成・権限付与などするときのコマンド覚書です。

SQL
grant all privileges on db_name.* to db_user@'localhost' identified by 'db_pass' with grant option;

これは、以下の意味となります。

SQL
grant [権限] on [適用対象のデータベース].[適用対象のテーブル] to 'ユーザ名'@'ホスト名' identified by 'パスワード';
  • with grant option を指定すると他のユーザーにも同等の権限を与えられるようになる。
  • grant all privilegesprivileges は省略可能で grant all on db_name~ でもよい。
  • 対象ユーザーが未作成の場合は create 文を使わなくても grant 文で作成可能。

参考URL

MySQLでユーザを作成し、権限を設定する方法
ユーザーを作成する(CREATE USER文)
GRANT -- アクセス権限の定義
IBM Knowledge Center | WITH GRANT OPTION キーワード

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?