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

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

More than 3 years have passed since last update.

概要

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;
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
ユーザーは見つかりませんでした