Mac M1运行mongosqld时libssl.1.1.dylib未加载错误求助
解决mongosqld启动时缺失libssl.1.1.dylib的问题
启动mongosqld时出现以下错误:
Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib Referenced from: <D7CD9CBA-9A7D-35DA-A053-8ACA1C7DB435> /usr/local/bin/mongosqld Reason: tried: '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file, not in dyld cache) zsh: abort mongosqld
已尝试但无效的操作:
brew install openssl@1.1 brew link openssl@1.1 --force
系统Brew配置信息:
HOMEBREW_VERSION: 3.6.13 ORIGIN: https://github.com/Homebrew/brew HEAD: 747829334b4bb3ab0d67a4c8bd9f4bf78c491c49 Last commit: 3 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: b3eef87fdbfea4c732bd31b0e373ca4f09718670 Core tap last commit: 6 minutes ago Core tap branch: master HOMEBREW_PREFIX: /opt/homebrew HOMEBREW_CASK_OPTS: [] HOMEBREW_MAKE_JOBS: 8 Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby CPU: octa-core 64-bit arm_firestorm_icestorm Clang: 14.0.0 build 1400 Git: 2.37.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git Curl: 7.84.0 => /usr/bin/curl macOS: 13.0.1-arm64 CLT: 14.1.0.0.1.1666437224 Xcode: 14.1 Rosetta 2: false
问题原因
你的设备是arm64架构Mac,Homebrew默认安装路径为/opt/homebrew,但mongosqld硬编码了依赖查找路径为Intel架构的Homebrew前缀/usr/local/opt/openssl@1.1,导致无法找到已安装的openssl库。
解决方案
方案1:修改mongosqld的依赖路径(推荐)
使用install_name_tool工具修改mongosqld的依赖指向,将其切换到arm64版本的openssl路径:
# 确认openssl@1.1的实际安装路径 ls /opt/homebrew/opt/openssl@1.1/lib/libssl.1.1.dylib # 修改libssl的依赖路径 sudo install_name_tool -change /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib /opt/homebrew/opt/openssl@1.1/lib/libssl.1.1.dylib /usr/local/bin/mongosqld # 同步修改libcrypto的依赖路径(mongosqld通常也依赖该库) sudo install_name_tool -change /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib /opt/homebrew/opt/openssl@1.1/lib/libcrypto.1.1.dylib /usr/local/bin/mongosqld
修改完成后直接启动mongosqld即可。
方案2:通过Rosetta 2运行mongosqld
- 打开访达,进入
/Applications/Utilities,找到「终端」 - 右键点击终端,选择「显示简介」,勾选「使用Rosetta打开」
- 在该Rosetta终端中重新安装依赖与mongosqld:
brew install openssl@1.1 mongosqld brew link openssl@1.1 --force
之后在该终端中启动mongosqld即可正常运行。
方案3:重新安装适配arm64的mongosqld
若上述方案无效,卸载现有mongosqld后,从MongoDB官方下载arm64版本的mongosqld安装包,手动替换现有文件。
内容的提问来源于stack exchange,提问作者Mihir
相关产品推荐
相关产品推荐

