1
3

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

MySQL8.0からMySQL5.7に戻す

Last updated at Posted at 2018-11-07

背景

この前brew upgradeをしたら、MySQLのバージョンが8.0に上がってしまっていて

$ mysql.server start
Password:
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/****.local.pid).

と起動しようにもできなくなった。
MySQLを急ぎで使う必要があったため、もともと使っていたMySQL 5.7に戻すことにしたのだが、ググると様々な情報があり惑わされたので、自分が行ったことをここにメモる。
(自分が調べた中には、一度/usr/local/var/mysql以下の削除を伴う方法などもあったのだが、自分は特に削除などは行わずに復旧できたので、データを消したくない場合にも有効)

環境

  • macOS Sierra(10.12.4)
  • Homebrew(1.8.0)
  • MySQL(5.7.12 -> 8.0.12にしてしまった)

注意事項

念の為、事前に/usr/local/var/mysql以下のバックアップを忘れずに行う。

手順

$ mysql --version
mysql  Ver 8.0.12 for osx10.12 on x86_64 (Homebrew)

として、MySQLのバージョンが8.0系であることを確認したら

$ brew uninstall mysql

として、MySQL 8.0をアンインストール。

すると

Uninstalling /usr/local/Cellar/mysql/8.0.12... (255 files, 233.3MB)
mysql 5.7.12 is still installed.
Remove all versions with `brew uninstall --force mysql`.

と言われ、MySQL5.7がまだインストールされていることに気づき

$ brew link mysql
Linking /usr/local/Cellar/mysql/5.7.12... 93 symlinks created

としてmysql5.7のsymlinkを再設定。あとは

$ mysql --version

としてmysqlのバージョンを確認し、mysql5.7になっていればok。

mysql.server start                                                                                                                                                                                          [/usr/local/var]
Starting MySQL
........ SUCCESS!

無事起動することができた。

最後に

brew upgradeは慎重に。

参考

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?