运行 `rails server` 时出现 MySQL 错误
当我运行 rails server
时出现以下错误
Could not find mysql2-0.2.7 in any of the sources
有什么想法吗?我该如何解决这个问题?
提前致谢 ;-)
I get the following error when I run rails server
Could not find mysql2-0.2.7 in any of the sources
Any ideas? How do i fix this?
Thanks in advance ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果由于某种原因你在 gem 旁边指定了版本号,请尝试删除它,只需
在 Gemfile 中执行 gem 'mysql2',
然后运行“bundle install”,就可以了
If for some reason you have the version number specified next to the gem, try removing it, just do
gem 'mysql2' in your Gemfile,
Then run "bundle install", that should do it
您需要阅读 Bundler:http://gembundler.com/
Bundler 默认包含在 Rails 3 中。应用程序的根目录中有一个名为
You should only use
mysql
或mysql2
的文件。我推荐mysql2
因此,如果您的 Gemfile 中有多个,请删除其他的。然后确保运行bundle install
。有关在 OSX 上设置 MySQL 和 Rails 的完整说明,请查看此博客文章:
OSX Snow Leopard 上的首选 Rails 3 和 MySQL 安装
You need to go read up on Bundler: http://gembundler.com/
Bundler is included in Rails 3 by default. At the root of your app is a file called
You should only use
mysql
ormysql2
. I recommendmysql2
so if you have more than one in your Gemfile then remove the others. Then make sure you runbundle install
.For complete instructions on setting up MySQL and Rails on OSX, check out this blog post:
Preferred Rails 3 and MySQL Installation on OSX Snow Leopard