昨晚将Mac升级后,nginx和mysql无法启动,提示错误如下:
yanghang@doit:~/work/study/php/test> nginx -s reload
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/bin/nginx
Reason: image not found
Abort trap: 6
发现是openssl升级到1.1.1后导致的,原来mysql和nginx依赖的是1.0.0,在将openssl删除后,重新安装后,还是无法使用:
yanghang@doit:~/work/study/php/test> brew remove openssl
Error: Refusing to uninstall /usr/local/Cellar/openssl@1.1/1.1.1f
because it is required by apr-util, curl-openssl, freetds, glib, libevent, libpq, libssh2, mysql@5.6, nghttp2, nginx, openldap, php@7.3, python, python@2, rtmpdump and wget, which are currently installed.
You can override this and force removal with:
brew uninstall --ignore-dependencies openssl
yanghang@doit:~/work/study/php/test> brew uninstall --ignore-dependencies openssl
Uninstalling /usr/local/Cellar/openssl@1.1/1.1.1f... (8,057 files, 18MB)
openssl@1.1 1.1.1d is still installed.
Run `brew uninstall --force openssl@1.1` to remove all versions.
yanghang@doit:~/work/study/php/test> brew uninstall --force openssl@1.1
Uninstalling openssl@1.1... (7,983 files, 17.9MB)
yanghang@doit:~/work/study/php/test> brew install openssl
重新安装后,将openssl重新选择到老版本,然后nginx启动成功了:
yanghang@doit:~/work/study/php/test> brew switch openssl 1.0.0
Error: openssl does not have a version "1.0.0" in the Cellar.
openssls installed versions: 1.0.2o_2
yanghang@doit:~/work/study/php/test> brew switch openssl 1.0.2o_2
Cleaning /usr/local/Cellar/openssl/1.0.2o_2
yanghang@doit:~/work/study/php/test> brew services restart nginx
Stopping `nginx`... (might take a while)
==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)s
然后再启动mysql的时候,还是启动不了,
yanghang@doit:~/work/study/php/test> sudo mysql.server start
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/Cellar/mysql@5.6/5.6.41/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.6/5.6.41/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.6/5.6.41/bin/my_print_defaults
Reason: image not found
/usr/local/Cellar/mysql@5.6/5.6.41/bin/mysqld_safe: line 183: 24075 Abort trap: 6 nohup /usr/local/Cellar/mysql\@5.6/5.6.41/bin/mysqld --basedir=/usr/local/Cellar/mysql\@5.6/5.6.41 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql\@5.6/5.6.41/lib/plugin --user=mysql --log-error=yh.err --pid-file=/usr/local/var/mysql/yh.pid < /dev/null > /dev/null 2>&1
ERROR! The server quit without updating PID file (/usr/local/var/mysql/yh.pid).
然后查看对应的/usr/local/var/mysql/yh.err
313382 2020-04-13 10:31:22 34937 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
313383 2020-04-13 10:31:22 34937 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
313384
313385 2020-04-13 10:31:22 34937 [ERROR] Aborting
313386
313387 2020-04-13 10:31:22 34937 [Note] Binlog end
313388 2020-04-13 10:31:22 34937 [Note] /usr/local/opt/mysql@5.6/bin/mysqld: Shutdown complete
原来不建议已root启动,所以直接执行
yanghang@doit:~/work/study/php/test> mysql.server start
Starting MySQL
./usr/local/Cellar/mysql@5.6/5.6.41/bin/mysqld_safe: line 138: /usr/local/var/mysql/yh.err: Permission denied
/usr/local/Cellar/mysql@5.6/5.6.41/bin/mysqld_safe: line 138: /usr/local/var/mysql/yh.err: Permission denied
/usr/local/Cellar/mysql@5.6/5.6.41/bin/mysqld_safe: line 183: /usr/local/var/mysql/yh.err: Permission denied
/usr/local/Cellar/mysql@5.6/5.6.41/bin/mysqld_safe: line 138: /usr/local/var/mysql/yh.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/var/mysql/yh.pid).
于是将/usr/local/var/mysql/yh.err
权限改了一下,能启动了。done!!!