LoadError:无法在rake db:create上加载这样的文件——mysql2/mysql2

LoadError:无法在rake db:create上加载这样的文件——mysql2/mysql2,mysql,ruby-on-rails,Mysql,Ruby On Rails,运行rake db:create时,出现以下错误: LoadError: cannot load such file -- mysql2/mysql2 /Users/vitorqueiroz/dev/pipeline/config/application.rb:10:in `<top (required)>' /Users/vitorqueiroz/dev/pipeline/Rakefile:5:in `<top (required)>' (See full trace

运行
rake db:create
时,出现以下错误:

LoadError: cannot load such file -- mysql2/mysql2
/Users/vitorqueiroz/dev/pipeline/config/application.rb:10:in `<top (required)>'
/Users/vitorqueiroz/dev/pipeline/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
--

有其他选择吗?

你可以试试

bundle exec rake db:create
确保已加载捆绑的宝石

你可以试试

bundle exec rake db:create
确保已加载捆绑的宝石


感谢@mrzasa的回复,指出--srcdir=/usr/local/include/mysql是我的问题。如果您在本地安装了MySQL8版本,那么mysql2 gem将无法在项目中正确安装。我不得不删除它并安装mysql版本5.7,然后重新安装我的mysql2 gem,一切正常。感谢@mrzasa的回复,指向--srcdir=/usr/local/include/mysql是我的问题。如果您在本地安装了MySQL8版本,那么mysql2 gem将无法在项目中正确安装。我必须删除它并安装mysql版本5.7,然后重新安装我的mysql2 gem,一切正常。谢谢!我想没有其他选择了。谢谢!我认为没有其他选择。