Ruby on Rails mysql2 驱动程序无法连接,mysql 客户端/telnet 可以
我在 mysql2 gem 上遇到了一个奇怪的问题。我有一个 Dreamhost VPS 和一个 Dreamhost MySQL VPS。从 VPS 到 MySQL VPS,以下数据库.yml 工作正常:
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: [redacted]
pool: 15
username: [redacted]
password: [redacted]
host: mysql.medlapps.com
但是,在我的 MacBook 上运行 rails s -e=product
或我们新的 Limestone 专用服务器上的相同代码会导致连接错误:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/client.rb:43:in `connect': Can't connect to MySQL server on 'mysql.medlapps.com' (61) (Mysql2::Error)
MySQL VPS 允许 Dreamhost 网络外部的连接。使用 Liya(Mac OS X MySQL GUI 客户端)以及 telnet mysql.medlapps.com 3306 都可以毫无问题地进行连接。这只是 mysql2 gem 或它的配置的问题。
编辑:mysql -h mysql.medlapps.com -u [redacted] -p[redacted]
也适用于我们新的专用服务器。这让我相信这是 mysql2 驱动程序/Rails 或它们的配置方式的问题。
编辑 2:事实证明这不是 MySQL 或 mysql2 gem 的问题。其他东西在启动时无法加载。运行基本的 hello world Rails 应用程序在我们新的专用盒子上运行良好。然而,我们遇到的问题是我们的网站应用程序无法在生产模式下运行。服务器挂起并且没有提供任何错误。当我们解决问题后,将保持帖子更新。
任何想法/帮助将不胜感激!
I'm encountering an odd issue with the mysql2 gem. I have a Dreamhost VPS and a Dreamhost MySQL VPS. Going from the VPS to the MySQL VPS, the following database.yml works fine:
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: [redacted]
pool: 15
username: [redacted]
password: [redacted]
host: mysql.medlapps.com
However, running rails s -e=production
on my MacBook or the same code our new Limestone dedicated server results in a connection error:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/client.rb:43:in `connect': Can't connect to MySQL server on 'mysql.medlapps.com' (61) (Mysql2::Error)
The MySQL VPS is allowing connections outside the Dreamhost network. Using Liya (a Mac OS X MySQL GUI client) as well as telnet mysql.medlapps.com 3306
both are able to connect with no issues. This is only an issue with the mysql2 gem, or configuration with it.
Edit: mysql -h mysql.medlapps.com -u [redacted] -p[redacted]
also works on our new dedicated server. This leads me to believe it is an issue with the mysql2 driver / Rails or how they are configured.
Edit 2: Turns out this is not an issue with MySQL or mysql2 gem. Something else is failing to load on startup. Running a basic hello world Rails app works fine on our new dedicated box. However the issue we are having is that our website app fails to run in production mode. The server hangs and provides no errors. Will keep post updated when we figure out the issue.
Any thoughts / help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论