LoginSignup
16
7

More than 3 years have passed since last update.

MacでMySQL起動時にエラー(dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib)

Posted at

はじめに

久々にMacにインストールしているMySQLを使おうと思ったらエラーが発生したので、その解決方法を記載します。
1年くらい前は正常に使えていたのにな。。。

環境

  • macOS Catalina 10.15.4(19E287)
  • MySQL 5.7.21

エラー内容

MySQLを起動しようとしたら下記のエラーが発生!!

% mysql.server start

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/Cellar/mysql/5.7.21/bin/my_print_defaults
  Reason: image not found
Starting MySQL
.dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/Cellar/mysql/5.7.21/bin/my_print_defaults
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/Cellar/mysql/5.7.21/bin/my_print_defaults
  Reason: image not found
/usr/local/Cellar/mysql/5.7.21/bin/mysqld_safe: line 198: 38133 Abort trap: 6           nohup /usr/local/Cellar/mysql/5.7.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.7.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.7.21/lib/plugin --log-error=htanaka.local.err --pid-file=/usr/local/var/mysql/htanaka.local.pid < /dev/null >> /usr/local/var/mysql/htanaka.local.err 2>&1
 ERROR! The server quit without updating PID file (/usr/local/var/mysql/XXXXX.local.pid).

解決方法

エラーログを見る限り、どうやらopensslが読み込めないらしい。。。入っていないのかな?

% brew update
% brew install openssl

Warning: openssl@1.1 1.1.1f is already installed and up-to-date
To reinstall 1.1.1f, run `brew reinstall openssl@1.1`

入っているっぽいな。。。入れ直してみる。

% brew reinstall openssl

==> Reinstalling openssl@1.1 
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1f.catalina.bottle.tar.gz
==> Pouring openssl@1.1-1.1.1f.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1f: 8,057 files, 18MB

入れ直しても、エラーは発生!!
どうやら、バージョンの問題がある模様。最新版が入っていたので、バージョンを落としてみよう。

% brew switch openssl 1.0.2r

Cleaning /usr/local/Cellar/openssl/1.0.2r
Cleaning /usr/local/Cellar/openssl/1.0.2q
Opt link created for /usr/local/Cellar/openssl/1.0.2r

解決!!
MySQLが起動できるようになった!!

% mysql.server start      

Starting MySQL
. SUCCESS! 

opensslをupdateした覚えはないのだけどな。。。
macOSを更新した時に勝手に上がったのかな。。。
とりあえず解決しましたので、お疲れ様でした。

16
7
1

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
16
7