LoginSignup
11
9

More than 5 years have passed since last update.

mysql 5.7 以降の user 追加について

Posted at

brew ではいる mysql が 5.7.10 というのになってて、ユーザー追加にはまった。

CREATE USER 'hoge'@'localhost' IDENTIFIED BY 'hage';

なんかGRANTでいきなり追加ができなくなったらしいので、上記のようにすると、mysql.user の plugin のカラムにハッシュ値みたいのが入る。

mysql のエラーには

The plugin '*00000000000034D1E9A887E4A913CB219E' used to authenticate user 'hoge'@'localhost' is not loaded. Nobody can currently login using this account.

みたいのが出る。

mysql -uhoge -p でも同じような plugins がどうしたみたいなエラーに。

CREATE USER 'hoge'@'localhost' IDENTIFIED WITH mysql_native_password BY 'hage';

とかが正しいらしいのでそうするが、なんかだめ。

結果としては過去の DB がのこってて

2016-01-28T11:36:35.274313Z 0 [ERROR] Column count of performance_schema.events_statements_history_long is wrong. Expected 41, found 40. Created with MySQL 50619, now running 50710. Please use mysql_upgrade to fix this error.
~snip~
2016-01-28T11:36:35.457764Z 0 [ERROR] Native table 'performance_schema'.'session_variables' has the wrong structure
2016-01-28T11:36:35.457876Z 0 [ERROR] Incorrect definition of table mysql.db: expected column 'User' at position 2 to have type char(32), found type char(16).
2016-01-28T11:36:35.457893Z 0 [ERROR] mysql.user has no `Event_priv` column at position 28
2016-01-28T11:36:35.471894Z 0 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
2016-01-28T11:36:35.472106Z 0 [Note] /usr/local/Cellar/mysql/5.7.10/bin/mysqld: ready for connections.

みたいなログが大量に出てた。/(^o^)\

ので、brew uninstall mysql して、/usr/local/var/mysql を削除して入れなおしたらすべてうまくいきました。

mysql_upgrade でも良かったんだろうけど、別に未練はなかったので。

11
9
1

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
11
9