9
8

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.

【homebrew】MacのMySQLを5.6から8.0に更新

Posted at

概要

  • マイグレーションツールを使いたい!
  • でも、Mysql5.7以上しか対応していない!
  • あげるかー! ← 今に至る

手順

(1) HomeBrewのバージョンを確認

$ mysql --version
mysql  Ver 14.14 Distrib 5.6.47, for osx10.15 (x86_64) using  EditLine wrapper

(2) Homebrewの更新

$ brew update

(3) mysqlを8.0.21に更新(2020/08/22時点)


$ brew install mysql

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
qcad                                                                transnomino                                                         wormhole

==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.21_1.catalina.bottle.tar.gz
Already downloaded: /Users/banaoh/Library/Caches/Homebrew/downloads/0d017278caa06d8c2921f06801b920ebffaeb68cef50eb80973e70db449facc5--mysql-8.0.21_1.catalina.bottle.tar.gz
==> Pouring mysql-8.0.21_1.catalina.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld --initialize-insecure --user=banaoh --basedir=/usr/local/Cellar/mysql/8.0.21_1 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.21_1: 290 files, 291.2MB

(4) mysqlのバージョン確認(失敗)

$ mysql --version
mysql  Ver 14.14 Distrib 5.6.47, for osx10.15 (x86_64) using  EditLine wrapper

あれ、5.6のまま?
プロセスの確認、残ってたら削除


# プロセスの確認
$ ps ax | grep mysql
44146   ??  S      0:00.03 /bin/sh /usr/local/Cellar/mysql@5.6/5.6.47/bin/mysqld_safe
44255   ??  S      0:09.04 /usr/local/Cellar/mysql@5.6/5.6.47/bin/mysqld --basedir=/usr/local/Cellar/mysql@5.6/5.6.47
84116 s000  S+     0:00.00 grep mysql

# プロセスの削除
$ kill -9 44146
$ kill -9 44255

(4) mysqlのバージョン確認(成功)


$ mysql --version
mysql  Ver 8.0.21 for osx10.15 on x86_64 (Homebrew)

(5) mysqlの起動


$ mysql.server start
Starting MySQL
. SUCCESS!

トラブルシューティング

ケース1. 起動時に『ERROR! The server quit without updating PID file』 が出る

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

ケース2. 再インストールしたい

  • 下記の手順

# (1) アンインストール
$ brew uninstall mysql

# (2) mysqlの実体ファイルを削除 (DB消えるため、必要に応じてバックアップ)
$ sudo rm -rf /usr/local/mysql*

# (3) 再インストール
$ brew install mysql
9
8
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
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?