mySQL Not working with rails app

Hi I have a rails app that used to run, but now doesn’t. On the first
select the app makes I get the following error:

“Lost connection to MySQL server during query”

I can run the offending query from the mysql command line, and have no
problems with the DB with some existing php apps.

Any ideas?

It’s possibly a problem with the Ruby MySql bindings. Try ‘gem install
mysql’ and see if your problem goes away.

Dave Naffis wrote:

It’s possibly a problem with the Ruby MySql bindings. Try ‘gem install
mysql’ and see if your problem goes away.

Probably should have posted a little more detail, I tried that and it
bombed out when I tried to run it. I was pretty tired out from fighting
the problem before I started trying that, so I didn’t look deeply into
why it didn’t work. More just decided I needed more coffee…

I read briefly if your mysql is not stored in a ‘standard location’ it
wouldn’t work. I use debian and had it installed with a package into
/etc/mysql. Not sure if that is standard or not.

Perhaps I need beer instead of coffee…

Ben Marini wrote:

Joe C. wrote:

Hi I have a rails app that used to run, but now doesn’t. On the first
select the app makes I get the following error:

“Lost connection to MySQL server during query”

I can run the offending query from the mysql command line, and have no
problems with the DB with some existing php apps.

Any ideas?

What’s your config/database.yml file look like? You may have to define
the location of your mysql.sock file in the yaml file:

development:
adapter: mysql
database: something_dev
username: user
password: pass
socket: /var/lib/mysql/mysql.sock

Hi thanks, that’s exactly how I have it set. In fact if I take out the
socket line it gives an error message roughly stating “/tmp/mysql.sock
can’t be found”.

Joe C. wrote:

Hi I have a rails app that used to run, but now doesn’t. On the first
select the app makes I get the following error:

“Lost connection to MySQL server during query”

I can run the offending query from the mysql command line, and have no
problems with the DB with some existing php apps.

Any ideas?

What’s your config/database.yml file look like? You may have to define
the location of your mysql.sock file in the yaml file:

development:
adapter: mysql
database: something_dev
username: user
password: pass
socket: /var/lib/mysql/mysql.sock

Joe C. wrote:

Hi I have a rails app that used to run, but now doesn’t. On the first
select the app makes I get the following error:

“Lost connection to MySQL server during query”

I can run the offending query from the mysql command line, and have no
problems with the DB with some existing php apps.

Any ideas?

Hi Joe,

You may want to take a look in the mysql logs and grep for ‘mysql.user
table is not updated to new password format’ and if you find it disable
new password function. To be perfectly honest I don’t recall how to do
this, but it’s pretty common and you should be able to google for it.

Phil P.
Traffic Engineering
eMarketSouth
912.356.1140 x107
phil’remove me’@emarketsouth.com

On 8/21/06, Joe C. [email protected] wrote:

Dave Naffis wrote:

It’s possibly a problem with the Ruby MySql bindings. Try ‘gem install
mysql’ and see if your problem goes away.

Probably should have posted a little more detail, I tried that and it
bombed out when I tried to run it. I was pretty tired out from fighting
the problem before I started trying that, so I didn’t look deeply into
why it didn’t work. More just decided I needed more coffee…

Be sure you have gcc and the ruby-dev packages installed.

jeremy

Jeremy K. wrote:

On 8/21/06, Joe C. [email protected] wrote:

Dave Naffis wrote:

It’s possibly a problem with the Ruby MySql bindings. Try ‘gem install
mysql’ and see if your problem goes away.

Probably should have posted a little more detail, I tried that and it
bombed out when I tried to run it. I was pretty tired out from fighting
the problem before I started trying that, so I didn’t look deeply into
why it didn’t work. More just decided I needed more coffee…

Be sure you have gcc and the ruby-dev packages installed.

jeremy

Hi, problem is I compiled and installed ruby from source, so I am
outside the deb package orbit on that.

I recently installed ferret and the acts_as_ferret plugin but I’m
getting results that I just don’t understand. The model I’m using is for
products. The table contains fields ‘name’, ‘description’, ‘sku’,
‘model’. This is what I have put in my model:

acts_as_ferret :fields => { :sku => {}, :model => {}, ‘name’ => { :boost
=> 2, :store => Ferret::Document::Field::Store::YES }, ‘description’ =>
{ :boost => 1.5, :store => Ferret::Document::Field::Store::YES } },
:store_class_name => true

I have a couple of products called:
product 1: Armored Troopers Votoms Red Scopedog EX-01 Action Figure
product 2: Fate/Hollow Ataraxia Sakura Matou Grocery Shopping PVC Statue

If I search for ‘Armored’, it comes back correctly with product 1.
If I search for ‘Votoms’, it comes back with NOTHING
If I search for ‘figure’, it comes back with product 1
If I search for ‘Scopego’, it comes back with NOTHING

Similarly:

If I search for ‘fate’, it comes back with product 2
If I search for ‘shopping’ it comes back with NOTHING
If I search for ‘statue’ it comes back with product 2

I’m really not getting the logic with why it’s doing that. It seems like
it’s catching words that are in the beginning and near the end of the
product names, but not the middle. I’m not really familiar with how
ferret’s search algorithm works, but I’m assuming (yes, not a good
idea!) that it searches the entire product name.

Any help with this would be greatly appreciated. Thanks!

Best Regards,

Tamim

Ezra Z. wrote:

On Aug 21, 2006, at 1:32 PM, Joe C. wrote:

Probably should have posted a little more detail, I tried that
jeremy

Hi, problem is I compiled and installed ruby from source, so I am
outside the deb package orbit on that.

Hey Joe-

You need the native mysql bindings. If you installed mysql from
standard debian packages you should be able to get it to work with
the following command:

$ sudo gem install mysql – --with-mysql-config

Copy and paste that and make sure you keep the extra – it is needed.

-Ezra

Thanks for all the good advice, it’s appreciated!

Here’s what I’m getting when I try that:

nc1:~# gem install mysql – --with-mysql-config
Attempting local installation of ‘mysql’
Local gem file not found: mysql*.gem
Attempting remote installation of ‘mysql’
Updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-linux)

  1. mysql 2.7.1 (mswin32)
  2. mysql 2.7 (ruby)
  3. mysql 2.6 (ruby)
  4. mysql 2.5.1 (ruby)
  5. Cancel installation

2
Building native extensions. This could take a while…
extconf.rb:1: command not found: mysql_config --cflags
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/local/bin/ruby
–with-mysql-config
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
ruby extconf.rb install mysql – --with-mysql-config\n

Results logged to
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Hi Joe

You mention you’re using debian - is ruby installed from binary
packages or from source?

If it’s binary you should just be able to apt-get install
libdbd-mysql-ruby
If source make sure you have ruby-dev and build-essential* installed,
then try installing the gem again.

  • you probably don’t need all of build-essential, but there’s no harm
    in doing so

HTH,
Simon

On Aug 21, 2006, at 1:32 PM, Joe C. wrote:

Probably should have posted a little more detail, I tried that
jeremy

Hi, problem is I compiled and installed ruby from source, so I am
outside the deb package orbit on that.

Hey Joe-

You need the native mysql bindings. If you installed mysql from

standard debian packages you should be able to get it to work with
the following command:

$ sudo gem install mysql – --with-mysql-config

Copy and paste that and make sure you keep the extra -- it is needed.

-Ezra

Joe C. wrote:

[email protected] wrote:

Hi Joe

You mention you’re using debian - is ruby installed from binary
packages or from source?

If it’s binary you should just be able to apt-get install
libdbd-mysql-ruby
If source make sure you have ruby-dev and build-essential* installed,
then try installing the gem again.

  • you probably don’t need all of build-essential, but there’s no harm
    in doing so

HTH,
Simon

Hi, I am running Debian, but the stable Ruby package was 1.8.3 at the
time I started this - not good obviously. I searched for a 1.8.4
package but couldn’t find one, so I compiled and installed from source.

Any ideas what I need in this scenario? Re-download the source? Where
would I put it for it to be visible to the gem?

Argh!

Will these bindings even work with 1.8.4? According to the readme in
the gem package:
Requirement
MySQL 4.0.22/4.1.13/5.0.11
Ruby 1.8.2

I have ruby 1.8.4 and mysql 5.0.22.

Also, what the heck is this all about, I never had to do this before to
get a rails app running? What changed? Is this a compile option I
missed when I compiled ruby itself?

[email protected] wrote:

Hi Joe

You mention you’re using debian - is ruby installed from binary
packages or from source?

If it’s binary you should just be able to apt-get install
libdbd-mysql-ruby
If source make sure you have ruby-dev and build-essential* installed,
then try installing the gem again.

  • you probably don’t need all of build-essential, but there’s no harm
    in doing so

HTH,
Simon

Hi, I am running Debian, but the stable Ruby package was 1.8.3 at the
time I started this - not good obviously. I searched for a 1.8.4
package but couldn’t find one, so I compiled and installed from source.

Any ideas what I need in this scenario? Re-download the source? Where
would I put it for it to be visible to the gem?

Argh!

Umm, has no one used the acts_as_ferret plugin? Well, since no one has
responded to the original question below, I’m wondering what you guys
are using as the search engine for your sites. Any input would be
greatly appreciated. Thanks.

Best Regards,

Tamim

Ok this is resolved, steps included below for Debian users who are
having the same problem:

The root of the problem when I went off the reservation and used a
testing package for mySQL in my Sarge distro (needed 5.0.x instead of
the Sarge 4.0.x). This caused the gem install mysql to error.

When I upgraded, libmysqlclient12 remained. So I removed that:

apt-get remove libmysqlclient12

Also I removed all ancillary ruby packages since I did a manual
compile/install. There were probably a few conflicts in the list of
installed packages, so I decided to clean things up.

dpkg -l | grep ruby

apt-get remove libruby1.8

apt-get remove libmysql-ruby1.8

apt-get remove libmysql-ruby

Next I made sure I had the correct libmysqlclient package:

apt-get install libmysqlclient15-dev --fix-missing

Finally, I optimistically attempted to run the gem install:

gem install mysql

And that finally ran without error. I then launched my app using
mongrel, and the lost connection error was gone.

Great blogs for Ruby On Rails developers.

Tamim,

I must admit I am not a Ferret/Lucene expert by any means but I will
share
my little knowledge if it helps you. I’m using ferret and the plugin and
I
must say that it makes things really easy if you have simple
requirements.
The project I am working on is more complex than “simple requirements”
but
after a lot of digging in the code I have figured almost all the things
that
I need. Check the code for the plugin and for ferret and you will see
that
you can modify the analyzers/tokenizers (how you analyze a query and how
you
separate the query into words). For example, the standard query looks
for
non-alphanumeric characters to separate words. So “Fate/Hollow” would be
recognized as two separate words. Also I think you might have misspelled
your example when you searched for “Scopego” and your product is named
“Scopedog”. I must say, though, that if you searched for “Scopedo” it
would
not find anything but if you searched for “Scopedo*” it should find your
product. I’m still a ways to go on my project but so far I have been
pleased
greatly with ferret. My only concern is that there have been a few
segfaults
here and there but the developer tells me that things like that will get
ironed out by the stable release.

Hope this helps a bit,

Adrian M.

On 8/21/06, Tamim A. [email protected] wrote:

:store_class_name => true
Similarly:


Adrian Esteban Madrid

Great blogs for Ruby On Rails developers.

Great blogs for Ruby On Rails developers.