0
0

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 3 years have passed since last update.

Mysqlでユーザの作成と権限の付与をひとまとめで行った際に発生するエラーに関して

Posted at

Mysqlの参考書を勉強中に下記問題に遭遇しました。

問題

下記コードは、権限を付与するGRANT文を使ってユーザの新規作成も同時に行うというものです。

grant all privileges on basic.* to myusr@localhost identified by '12345';

しかし、これを実行したところ下記エラーが発生しました。

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 '12345'' at line 1

原因

調べたところバージョン8以降はユーザ作成と権限付与を同時に行うことは出来なくなっているというものでした。

解決策

バージョン8以降は

1、ユーザの作成
CREATE USER user IDENTIFIED BY '12345';
2、権限の付与
grant all privileges on basic.* to myusr@localhost;

と、ユーザ作成と権限の付与を分ける必要があるそうです。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?