Ruby on Rails-->Mysql2::Error 在“等待初始通信数据包”时丢失与 MySQL 服务器的连接,系统错误:0
你好 我刚刚开始使用 Ruby on Rails。我尝试使用 WebRick 和 MySQL 5.5、Windows XP 启动我的第一个“HelloWorld”应用程序
在 Firefox 中,我可以在“localhost:3000”上看到 Rails 标准页面,但如果我单击“关于您的应用程序环境”链接或尝试查看localhost:3000/demo/index/ 上的一个非常基本的“hello world”页面我收到错误(一两分钟后)
“无法连接:在‘读取初始通信’时丢失与 MySQL 服务器的连接数据包',系统错误:0。Rails
3.0.7 MySQL 5.5 宝石1.8.1 红宝石 1.9.2p180 赢得XP 32 在各种版本上尝试了 mysql 和 mysql2 gems。 数据库似乎通过控制台工作正常。 也尝试过无密码连接 使用utf8并在database.yml中声明。 尝试https://github.com/ghazel/mysql2/commit/a9515ed75f3b7a7ce2813a364a0e7ede66394a41 尝试完全关闭防火墙
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_db
pool: 5
username: simple
password:
host: localhost
port: 3000
帮助我!!!!好郁闷啊……
Hi
I just started on Ruby on Rails. I try to launch my first 'HelloWorld' app using WebRick and MySQL 5.5, Windows XP
In firefox I can see the Rails standart page on "localhost:3000" but if I click on the link "about your apps environment" or try to see a pretty basic "hello world" page on localhost:3000/demo/index/ i get the error(after a minute or 2)
"Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 0.
Rails 3.0.7
MySQL 5.5
Gem 1.8.1
Ruby 1.9.2p180
Win XP 32
Tried both mysql and mysql2 gems on various versions.
The database seems to work fine through the console.
Tried also to connect with no password
Using utf8 and stating that in the database.yml.
tried https://github.com/ghazel/mysql2/commit/a9515ed75f3b7a7ce2813a364a0e7ede66394a41
tried to turn off firewalls completely
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_db
pool: 5
username: simple
password:
host: localhost
port: 3000
Help me!!!! So frustrated.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正在尝试将 MySQL 连接连接到 Mongrel 套接字,因此这不会很好地工作,因为您的应用程序在尝试进行数据库调用时只会调用自身。
您可能应该将其更改为默认端口 3306,或者将其保留,让配置默认值发挥作用。
It looks like you're trying to connect your MySQL connection to the Mongrel socket, so that's not going to work very well, as your application will just call itself when trying to make a database call.
You should probably change that to the default port 3306, or just leave it out and let the configuration defaults come into play.