LoginSignup
1
0

More than 1 year has passed since last update.

mysqlが起動しない

Last updated at Posted at 2022-11-15

環境

macOS Monterey(12.6)
MySQL 8.0.29(Home Brew)

現象

Mac本体を再起動したらrails sでサーバの起動ができなくなりました。
MySQLを単体で起動させようとしても
「ERROR! The server quit without updating PID file」というのが出ます。
(PID fileが無いというのは直接的な原因ではない)

$ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/8.0.29_1/bin/mysqld_safe: line 199: 33199 Abort trap: 6           env MYSQLD_PARENT_PID=33088 nohup /usr/local/Cellar/mysql/8.0.29_1/bin/mysqld --basedir=/usr/local/Cellar/mysql/8.0.29_1 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/8.0.29_1/lib/plugin --log-error=MacBook-Air.local.err --pid-file=/usr/local/var/mysql/MacBook-Air.local.pid < /dev/null >> /usr/local/var/mysql/MacBook-Air.local.err 2>&1
 ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Air.local.pid).

エラーログを見てみる

/usr/local/var/mysql/MacBook-Air.local.err
icu4cのlibicuuc.70.dylibというライブラリが見つからないとか。

/usr/local/var/mysql/MacBook-Air.local.err
Library not loaded: '/usr/local/opt/icu4c/lib/libicuuc.70.dylib'
  Referenced from: '/usr/local/Cellar/mysql/8.0.29_1/bin/mysqld'
  Reason: tried: '/usr/local/opt/icu4c/lib/libicuuc.70.dylib' (no such file), '/usr/local/lib/libicuuc.70.dylib' (no such file), '/usr/lib/libicuuc.70.dylib' (no such file), '/usr/local/Cellar/icu4c/71.1/lib/libicuuc.70.dylib' (no such file), '/usr/local/lib/libicuuc.70.dylib' (no such file), '/usr/lib/libicuuc.70.dylib' (no such file)

/usr/local/opt/icu4c/lib/の中

$ ls -la /usr/local/opt/icu4c/lib/ | grep libicuuc
-r--r--r--   1 devzooiiooz  staff   1701880 11 15 14:40 libicuuc.71.1.dylib
lrwxr-xr-x   1 devzooiiooz  staff        19  4  8  2022 libicuuc.71.dylib -> libicuuc.71.1.dylib
-r--r--r--   1 devzooiiooz  staff   2678240  4  8  2022 libicuuc.a
lrwxr-xr-x   1 devzooiiooz  staff        19  4  8  2022 libicuuc.dylib -> libicuuc.71.1.dylib

要するにmysqlではlibicuucのバージョン70を見ようとしているのに71.1にバージョンアップされたので見つからない。

解決方法

色々とやったのですが、結局brewのupdateとicu4cの再インストールで解決しました。

$ brew update && brew reinstall icu4c
==> Reinstalling icu4c 
==> Pouring icu4c--71.1.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/icu4c/71.1: 262 files, 76.2MB
==> Running `brew cleanup icu4c`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Upgrading 3 dependents of upgraded formula:
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
mysql 8.0.29_1 -> 8.0.31, node 18.11.0 -> 19.0.1, postgresql@14 14.5_5 -> 14.6
以下略

MySQLのアップデートが終わったら

rootのパスワード無しでMySQLがインストールされるので
brewのメッセージの通りに「mysql_secure_installation」を投入する。
(既存のDBには影響を与えません)

==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation
$ mysql_secure_installation
..
略
..
All Done!

適宜質問に答えていく。
これで解決しました。午後がつぶれた…。

参考

ここの「icu4c をインストールし直す」が一番参考になりました。ありがたや。
phpがdyld: Library not loaded: /usr/local/opt/icu4c/lib/libicuio.68.dylibエラーで動かなくなった

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