Lost connection to MySQL server during query


#1

I just downloaded and installed Ruby on Rails to a Win XP SP1 OS using
XAMPP.
I started going through the beginner tutorials at rubyonrails.org. It
appears as though Ruby on Rails is operating properly until I try to
access the MySQL database I created for it. Then the browser displays a
detailed statement created by Ruby. It is titled:

ActiveRecord::StatementInvalid in Recipe#New

Recipe is the table I created in the new database. The error message
displayed next states:

Mysql::Error: Lost Connection to MySQL server during query: SHOW FIELDS
FROM recipes

I checked the MySQL error log I get:

[Warning] mysql.user table is not updated to new password format;
Disabling new password usage until mysql_fix_prifilege_tables is run

I ran the script and recieved a lot of error messages from mysql,
stopped and restarted mysql, still no improvements and the same error
messages are generated.

I also tried a variety of changes to config/database.yml file.

If anyone has any possible solutions or help on this problem it would be
appreciated very much. Thank you


#2

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#3

I had a similar problem and this was helpful:

http://wiki.rubyonrails.org/rails/pages/HowToUseMySQLRubyBindingsOnWin32/
http://jeroen.concept-q.biz/files/

-Jonathan.


#4

I had the same issue on CentOS 4.3;

ActiveRecord::StatementInvalid (Mysql::Error: Lost connection to MySQL
server during query: SHOW FIELDS FROM users):
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:180:inexecute’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:278:in
columns' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:734:incolumns’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1663:in
attributes_from_column_definition' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1185:ininitialize_without_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:236:in
initialize' /lib/account_system.rb:93:inident’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:354:in
call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:350:incall_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:339:in
before_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:331:inperform_action_without_benchmark’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:inperform_action’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:inprocess’
/app/controllers/application.rb:14:in process' /app/controllers/application.rb:13:inprocess’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch’
/var/www/rails_app/public/dispatch.cgi:10

Rendering
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)


#5

I encountered this error as well, when using WinXP with InstantRails and
WEBrick. I found that when I changed the password for my database user
to blank / empty string, everything started working fine. This is OK on
a test machine, but is obviously not an option for production boxes. :wink:


#6

Jonathan V. wrote:

I had a similar problem and this was helpful:

http://wiki.rubyonrails.org/rails/pages/HowToUseMySQLRubyBindingsOnWin32/
http://jeroen.concept-q.biz/files/

-Jonathan.

Jonathan, thank you - it worked!!

I did not use the msvrc70.dll file, I only used the mysql.so for MySQL
version 5.0.15 and copied it to the correct directory.

Al


#7

Ron Chaplin wrote:

Anonymous wrote:

I encountered this error as well, when using WinXP with InstantRails and
WEBrick. I found that when I changed the password for my database user
to blank / empty string, everything started working fine. This is OK on
a test machine, but is obviously not an option for production boxes. :wink:

I had the same issue. Also solved by adding in a blank password.
However, isn’t this considered a bug if we need to adapt our DB to “fix”
the rails system? I’m new to the ruby on rails community so please be
gentle.

Ok, so this is the solution I just found for my previous post. I did a
quick followup search and came across this,

http://www.ruby-forum.com/topic/51141#22397

By issuing the command

sudu mysqladmin -p old-password ENTER_PASSWORD_HERE

I was able to use the old hash style password and still have rails work.
It’s a workaround for something I still consider a bug.

HTH

Ron Chaplin
http://www.t73-softdesign.com

DEV:
Ubuntu 6.10
Apache 2.0
PHP 5.0
MySQL - 5.0.22


#8

Anonymous wrote:

I encountered this error as well, when using WinXP with InstantRails and
WEBrick. I found that when I changed the password for my database user
to blank / empty string, everything started working fine. This is OK on
a test machine, but is obviously not an option for production boxes. :wink:

I had the same issue. Also solved by adding in a blank password.
However, isn’t this considered a bug if we need to adapt our DB to “fix”
the rails system? I’m new to the ruby on rails community so please be
gentle.


#9

You are probably using an older version of MySQL which has different
password mechanism. You can fix the problem by simply updating to the
latest version of MySQL. I used to have the problem too, but after I
updated MySQL, it all works fine.


#10

Ken wrote:

You are probably using an older version of MySQL which has different
password mechanism. You can fix the problem by simply updating to the
latest version of MySQL. I used to have the problem too, but after I
updated MySQL, it all works fine.

Thanks for the suggestion.  I checked that, and its not it.

I loaded RadRails, and the data-browser worked fine.  However, the 

WEBrick apps yet again would not even try to connect to the DB server;
not failed password issues or whatever. Those I would see in the MySQL
server log. No connection attempt at all. I am so far rather
disappointed with my Ruby on Rail experience… not being able to even
follow along in the tutorial is rather disheartening.

I wiped my Ruby and Rails environments twice and reinstalled to make 

sure I hadn’t done something daft, but that didn’t help. This morning I
wiped Ruby & Rails again, and installed “Instant Rails” to see if I can
get any further down that road. If not, I suppose the next thing to do
is just set up a testing environment on my production Apache box to see
if a deployed application works there at all.

As a I say, rather disheartening.


–Michel Vaillancourt
Wolfstar Systems
www.wolfstar.ca


#11

Are you running the latest version of rails, the 1.2RC1? There is a
known issue with the WebBrick server that causes it to lose connection:

http://dev.rubyonrails.org/ticket/6687

I would either downgrade to 1.1 or wait for 1.2 final. However, since
you cannot connect at all it sounds like a different problem. You
should start going through the RubyonRails.org Wiki. There is a page on
this.


#12

I am getting this error as I try and do a very-basic Rails tutorial.
Between this thread and

http://wiki.rubyonrails.org/rails/pages/HowToUseMySQLRubyBindingsOnWin32/

it looks like I have about 15 different things I should try, half of
which involve installing some bundled rails, apache, and mySQL combo.

Am I a dick if I don’t want to start trying all these? I have Apache,
rails, and MySQL on this machine (XP box). They work fine. I want rails
to work now.

Sorry, just kinda frustrated…


#13

On 12/11/06, Michel R Vaillancourt removed_email_address@domain.invalid wrote:

get any further down that road. If not, I suppose the next thing to do is
just set up a testing environment on my production Apache box to see if a
deployed application works there at all.

   As a I say, rather disheartening.

I know that “lost connection” problem can also be caused by an older,
buggy
version of the mysql ruby adapter. I would recommend trying Instant
Rails
(as you said above). It includes an up to date mysql driver and should
not
have that problem.

Curt


#14

Okay, I’m in a better mood now. Fixed with this:

http://www.vandomburg.net/pages/mysql-ruby-windows

This one didn’t help:
http://rubyforge.org/projects/mysql-win

I think I’m going to have to build a few things before agreeing that RoR
is such a big timesaver… prolly see you around.

Matt


#15

installations (imo) are the biggest problem with rails and it’s
supporting cast (mysql drivers. os specific issues, server configs, etc)

after installation is solid, likely your biggest problem will be one
of documentation. Building your personal blogroll and improving your
ability intuit Rail’s philosophy with increase your ability to
deliver quality quickly.

As a final note, you should not consider that to power of rails can
replace solid best practices. (not saying you were, just wanted to
complete the general thought)

Good luck on your journey Matt - you’ll find the community a good
partner.
Jodi

General Partner
The nNovation Group inc.
www.nnovation.ca/blog


#16

On 3-Jan-07, at 3:59 PM, Jodi S. wrote:

As a final note, you should not consider that to power of rails

I think I’m going to have to build a few things before agreeing
that RoR is such a big timesaver… prolly see you around.

Matt


Posted via http://www.ruby-forum.com/.

correction on that (and a bottom quote. go figure!) - it’s the
supporting cast that’s the problem with installs - not with rails
specifically.

Jodi