Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
54
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

@yamateion

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

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

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
54
Help us understand the problem. What are the problem?