LoginSignup
2
1

More than 3 years have passed since last update.

brew upgradeしてmysqlが壊れたなら吹っ飛ばせば直る

Last updated at Posted at 2019-09-12

brew upgradeしたら壊れちまいやがった

$ mysql.server restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/GX1794.local.pid).

見事に使えなくなっています。
なんだかupgrradeした後のクラッシュはサポート対象外とかだそうで一旦ダウングレードとかして直してから再インストールが必要かとも思い、

$ brew postinstall mysql@5.7
==> Postinstalling mysql@5.7
==> /usr/local/Cellar/mysql@5.7/5.7.27_1/bin/mysqld --initialize-insecure --user=naoya.ohsaki --basedir=/usr/local/Cel
Last 15 lines from /Users/naoya.ohsaki/Library/Logs/Homebrew/mysql@5.7/post_install.01.mysqld:
2019-09-12 10:43:31 +0900

/usr/local/Cellar/mysql@5.7/5.7.27_1/bin/mysqld
--initialize-insecure
--user=naoya.ohsaki
--basedir=/usr/local/Cellar/mysql@5.7/5.7.27_1
--datadir=/usr/local/var/mysql
--tmpdir=/tmp

2019-09-12T01:43:31.093031Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-09-12T01:43:31.097131Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-09-12T01:43:31.097181Z 0 [ERROR] Aborting

ダウングレードしようにも落としてさえ来れない事態になっていました。

--datadir=/usr/local/var/mysql

解決策

・・・datadirのところ壊れちまったなら吹っ飛ばしてもいいんじゃ無いか?

そら、消えちゃえ。

sudo rm -rf /usr/local/var/mysql

それで、brew installを試みます。

brew install mysql
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
stone-soup

Warning: mysql: No available formula with the name "mysql-cluster"
'conflicts_with "mysql-cluster"' should be removed from mysql.rb.
Please report this to the homebrew/core tap!
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.17_1.mojave.bottle.tar.gz
Already downloaded: /Users/naoya.ohsaki/Library/Caches/Homebrew/downloads/bb1858c9aac3410b34d4e12a593da4870efc76e9dba3f77d2a5923ac6f5f02dd--mysql-8.0.17_1.mojave.bottle.tar.gz
==> Pouring mysql-8.0.17_1.mojave.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.17_1/bin/mysqld --initialize-insecure --user=naoya.ohsaki --basedir=/usr/local/Cellar/
==> 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.17_1: 284 files, 272.4MB

ハハハハハハハハ、動くじゃ無いか。手こずらせやがって。

$ mysql --version
mysql  Ver 8.0.17 for osx10.14 on x86_64 (Homebrew)

$ brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

$ ps aux | grep mysql
naoya.ohsaki     66169   0.0  0.0  4295688    848 s001  S+   11:12AM   0:00.01 grep mysql
naoya.ohsaki     65853   0.0  4.8  4879852 398528   ??  S    11:02AM   0:02.46 /usr/local/opt/mysql/bin/mysqld --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mysql/lib/plugin --log-error=GX1794.local.err --pid-file=GX1794.local.pid
naoya.ohsaki     65756   0.0  0.0  4287968   1240   ??  S    11:02AM   0:00.03 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
2
1
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
2
1