LoginSignup
7
6

More than 3 years have passed since last update.

MySQL 8で、mysql_upgradeがdeprecatedになった

Last updated at Posted at 2019-05-27

はじめに

 Mac上で、MySQLのバージョンを8.0.12から8.0.16にアップデートしたら、ユーザーを追加できなくなってしまいました。従来はmysql_upgradeを使って対処できましたが、8.0.16ではdeprecatedになった為、代わりの方法を書き残しておきます。

環境

バージョン
OS macOS 10.14.4
MySQL 8.0.16

現象

  1. こんな感じでユーザーを追加しようとすると、エラーが表示される

    $ echo "CREATE USER 'db_user'@'%' IDENTIFIED BY 'db_userXXX';" | mysql -uroot
    ERROR 3009 (HY000) at line 1: Column count of mysql.user is wrong. Expected 51, found 49. Created with MySQL 80012, now running 80015. Please use mysql_upgrade to fix this error.
    
  2. mysql_upgradeを使えと仰るので、使ってみると今度はdeprecatedとのこと

    $ mysql_upgrade -uroot
    The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server.
    To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade.
    The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand.
    It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.
    
  3. 上記メッセージで「MySQL binaryに、オプション"--upgrade=XXXXX"をつけろ」と仰るので、付けてみても上手くいかない

    $ mysql -uroot --upgrade=NONE
    mysql: [ERROR] unknown variable 'upgrade=NONE'.
    

結論

  • Mac上でのMySQL binaryはmysql.serverのことなので、以下のように使う

    $ mysql.server start --upgrade=FORCE
    Starting MySQL
    . SUCCESS!
    

感想

 MySQL 8.0.16から、mysql_upgradeはdeprecatedとのことなので、エラーメッセージで「Please use mysql_upgrade to fix this error.」と書くのは誤解を招くなぁ、と思いました。まだエラーメッセージまで手が回っていないだけで、そのうち修正されると思いますが。

参考

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