1
0

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】ワイルドカードを使って特定のデータベースにのみ権限を与える(GRANT)

1
Posted at

いつも忘れてしまうのでメモ。

piyo ユーザーに対して piyo_ というプレフィックスが付いたデータベース( piyo_sample とか)にのみ権限を与える場合。

mysql> GRANT ALL PRIVILEGES ON `piyo\_%`.* TO 'piyo'@'localhost';

`piyo\_%`.* について

_% は SQL でワイルドカードとして使われるため、_ をワイルドカードではなくそのままの文字列として認識させには \ でエスケープさせる必要がある。

% についてはワイルドカードとして使いたいのでエスケープはしない。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?