48
38

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.

mysql5.7 でユーザ追加の方法が変わったのでメモ

Posted at

概要

mysql 5.7 になって GRANT でユーザ追加できなくなりましたね。
いつも忘れてしまうので方法メモ。

手順

create user

create user が必須に。パスワードの設定もここで行う。パスワードに使用するロジックも同時に指定する。

CREATE USER 'anyusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'anypassword';

権限設定

GRANT ALL PRIVILEGES ON anydatabase.* TO 'anyusername'@'localhost';
FLUSH PRIVILEGES;

匿名ユーザ(userが空欄のユーザ)がいる場合、% よりも優先される。これにより安易に % で設定するのを防いでいると思われる。開発用で不要なら匿名ユーザを消してしまえばよい。

確認

SELECT user,host,plugin FROM mysql.user;
48
38
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
48
38

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?