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

Mysqlのgrant文でユーザ作成&権限付与しようとしてエラーが出たのでメモ

More than 1 year has passed since last update.

まず以下のように書いた。

mysql> grant all privileges on DB名.* to 'user'@'localhost' identified by 'password';

するとと以下のようなエラーが出た。

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password'' at line 1

mysqlのバージョンが8に変わって構文が変わったらしく、以下のようにユーザを作成してから、権限を与えると上手くいった。
mysql> create user 'user'@'localhost' identified by 'password';
mysql> grant all privileges on DB名.* to 'user'@'localhost';

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