LoginSignup
91
63

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-08-11

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

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';

91
63
3

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
91
63