6
2

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.

brew upgrade で mysql 8.0 にしてしまって bundle install で mysql2 でコケた時の話

Last updated at Posted at 2018-08-23

bundle install できない...

迂闊に brew update してしまい
bundle install するとこんなエラー吐かれた

Installing mysql2 0.4.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

:
:
:

An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.4'` succeeds before bundling.

バージョン確認する

mysql --version

# mysql  Ver 14.14 Distrib 8.0.xx, ...

8.0じゃぁ-ん

完全にMySQLを消し去る

MacでMySQL5.7をアンインストールする

を参考にアンインストール(ありがとうございます)

実際に打ったコマンド(コピペ面倒だったので $は省略してます)

brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

※STOP: ここで一旦PC再起動してください!!!

...本当に再起動しましたか?

再起動したら次へ👍

コマンドが使えないことを確認

mysql -v

# mysql: command not found

mysql 5.7をインストール

brew install mysql@5.7

パスを通す

echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

バージョン確認

mysql --version

# mysql  Ver 14.14 Distrib 5.7.20, ...

よくできました!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?