简体   繁体   English

无法启动 Rails 服务器 -> 无法加载此类文件 -- mysql2/mysql2 (LoadError)

[英]cannot start rails server -> cannot load such file -- mysql2/mysql2 (LoadError)

My rails application cannot start because mysql2 load error.我的 Rails 应用程序无法启动,因为 mysql2 加载错误。 I have tried many solutions, But none can't fix the problem.我尝试了很多解决方案,但没有一个解决不了问题。 Even the rake command can't be executed.连 rake 命令都无法执行。

rake aborted!
LoadError: cannot load such file -- mysql2/mysql2

My gemfile is:我的宝石文件是:

ruby '2.5.1'
gem 'rails', '~> 4.2.4'
gem 'mysql2', '~> 0.5.2'

Bundle installed successfully.捆绑安装成功。 Mysql installed correctly. Mysql 安装正确。 Yet the error occurs on MacOS.然而,错误发生在 MacOS 上。

Simply, uninstall and reinstall with the following command:只需使用以下命令卸载并重新安装:

gem install mysql2

If this is not working, you can try adding the following to your mysql_config :如果这不起作用,您可以尝试将以下内容添加到您的mysql_config

gem install mysql2 -v 0.4.4 -- --with-mysql-config=/usr/local/Cellar/mysql@5.6/5.6.42/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM