RoR 2.2.2 and MySQL -- HELP


#1

On Monday I “upgraded” from Rails 1.2.6 to 2.2.2 (also upgrading to
gem 1.3.1) but in the process have lost the ability to connect with my
mysql database. After finally reinstalling the MySQL gem with the
following gerrymandered command I found on a website (http://
involution.com/category/ruby-on-rails/):

sudo env ARCHFLAGS="-arch ppc64e$B!me(B gem install -V mysql –
-with-mysql-
include=/usr/local/mysql/include/ -with-mysql-lib=/usr/local/mysql/lib
-with-mysql-config=/usr/local/mysql/bin/mysql_config -with-mysql-dir=/
usr/local/mysql

It still doesn’t work! After attempting to access one of my views in
Firefox (3.0.3) I got the following error message:

!!! The bundled mysql.rb driver has been removed from Rails 2.2.
Please install the mysql gem and try again: gem install mysql.
/!\ FAILSAFE /!\ Wed Jan 07 10:57:23 -0500 2009
Status: 500 Internal Server Error
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9):
no suitable image found. Did find:
/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle: mach-o, but
wrong architecture - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/
mysql.bundle
/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

Simply running “gem install mysql” still doesn’t work (hence the hyper
specific command above).

I’m running Mac OS X 10.5.6 on a MacBook with Intel Core 2 Duo.

If anyone has any suggestions I’m all ears. I’ve been locked out of
my rails system for 2 days now and really need to get back to work.

Many thanks.

–Jean–


#2

On 7 Jan 2009, at 16:16, jabauer wrote:

-with-mysql-config=/usr/local/mysql/bin/mysql_config -with-mysql-dir=/
usr/local/mysql

You don’t want to be setting the arch to ppc64 though - you’re on an
intel machine and you’ve just told it to build a gem that will only
work on PowerPC machines! The architecture should be i386

The instructions on
http://danbenjamin.com/articles/2008/02/ruby-rails-leopard
are usually good.

Fred


#3

Thanks for pointing that out. Unfortunately, after I went through all
of Dan Benjamin’s directions it still failed to load the mysql gem. I
got the following error message:

sudo gem install mysql – --with-mysql-dir=/usr/local/mysql
Password:
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql – --with-mysql-dir=/usr/
local/mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no
*** 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.

Any thoughts? And many thanks.

–Jean–


#4

On 7 Jan 2009, at 17:23, jabauer wrote:

Thanks for pointing that out. Unfortunately, after I went through all
of Dan Benjamin’s directions it still failed to load the mysql gem. I
got the following error message:

Where is mysql installed ?

Fred


#5

On 7 Jan 2009, at 18:05, jabauer wrote:

have you tried sudo gem install mysql – --with-mysql-config=/usr/
local/mysql/bin/mysql_config
?

Fred


#6

On Jan 7, 12:40 pm, Frederick C. removed_email_address@domain.invalid
wrote:

Where is mysql installed ?

Fred

It should be in /usr/local/mysql/bin/mysql
At least that is what “which mysql” is giving me, although at this
point there may be more than one copy of the software on my machine.

–Jean–


#7

I’m having this EXACT same error and was about to post asking for
help. That last post by Fred fixed it. :slight_smile: However, something weird
happened. I have a database called testapp and it says it can’t find
it…I also had 2 mysql_config files on my system.


#8

have you tried sudo gem install mysql – --with-mysql-config=/usr/
local/mysql/bin/mysql_config
?

Fred

Just tried that and it seemed to work until I restarted the server and
got this error

dlsym(0x2727d10, Init_mysql): symbol not found - /usr/local/lib/ruby/
gems/1.8/gems/mysql-2.7/lib/mysql.bundle

I don’t know why it’s looking for mysql in /usr/local/lib/ruby when I
put it in /usr/local/mysql

Sorry to be so much trouble!

–Jean–


#9

On 7 Jan 2009, at 22:06, jabauer removed_email_address@domain.invalid wrote:

dlsym(0x2727d10, Init_mysql): symbol not found - /usr/local/lib/ruby/
gems/1.8/gems/mysql-2.7/lib/mysql.bundle

I don’t know why it’s looking for mysql in /usr/local/lib/ruby when I
put it in /usr/local/mysql

It’s not. It’s saying that it couldn’t find a function called
Init_mysql inside the gem. Have you checked whether that mysql.bundle
file is of the correct architecture? (which should match both your
machine and the mysql client libraries you have)


#10

Frederick C. wrote:

On 7 Jan 2009, at 22:06, jabauer removed_email_address@domain.invalid wrote:

dlsym(0x2727d10, Init_mysql): symbol not found - /usr/local/lib/ruby/
gems/1.8/gems/mysql-2.7/lib/mysql.bundle

I don’t know why it’s looking for mysql in /usr/local/lib/ruby when I
put it in /usr/local/mysql

It’s not. It’s saying that it couldn’t find a function called
Init_mysql inside the gem. Have you checked whether that mysql.bundle
file is of the correct architecture? (which should match both your
machine and the mysql client libraries you have)

/usr/local/bin/ruby extconf.rb install mysql – --with-mysql-dir=/usr/
local/mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no

As per the error log its searching for the library lmysqlclient.but its
not availbale.so first install the package libmysqlclient-dev.just check
this blog

http://genlinux.blogspot.com/2008/12/error-error-installing-mysql-error.html


#11

Just installed fink so I could have access to apt-get command. Now
when I try to install libmysqlclient-dev I get the following error

sudo apt-get install libmysqlclient-dev
Reading Package Lists… Done
Building Dependency Tree… Done
E: Couldn’t find package libmysqlclient-dev

What am I doing wrong?

Many thanks.

–Jean–


#12

have you tried sudo gem install mysql – --with-mysql-config=/usr/
local/mysql/bin/mysql_config
?

Fred

Just tried that and it seemed to work until I restarted the server and
got this error

dlsym(0x2727d10, Init_mysql): symbol not found - /usr/local/lib/ruby/
gems/1.8/gems/mysql-2.7/lib/mysql.bundle

I don’t know why it’s looking for mysql in /usr/local/lib/ruby when I
put it in /usr/local/mysql

Sorry to be so much trouble!

–Jean–


#13

On 8 Jan 2009, at 14:49, jabauer wrote:

Just installed fink so I could have access to apt-get command. Now
when I try to install libmysqlclient-dev I get the following error

You probably don’t want to go down that root at all unless you used
fink to install mysql.

like i mentioned before, you really should check that the architecture
of

  • the ruby interpreter
  • the mysql libraries
  • the mysql.bundle file created by gem

all match.

Fred


#14

Hi, I had to install 32 bit MySQL in order to get Rails running on my
Mac.


#15

zero0x wrote:

Hi, I had to install 32 bit MySQL in order to get Rails running on my
Mac.

If u are a debian user then after typing the below command just press
tab you will find the list of libraries as given below and select the
library suited to ur machine.i have installed libmysqlclient15-dev for
my ubuntu 8.04 64 bit

apt-get install libmysqlclient
libmysqlclient10-dev libmysqlclient15 libmysqlclient-dev
libmysqlclient12-dev libmysqlclient15-dev
libmysqlclient14-dev libmysqlclient15off


#16

zero0x wrote:

Hi, I had to install 32 bit MySQL in order to get Rails running on my
Mac.

OS X 10.5.
This worked for me too – if you are real sure that you’ve installed the
gem as suggested elsewhere here, but are still seeing:
dlsym/xxxx Init_mysql): symbol not found
/gems/mysql-2.7/lib/mysql.bundle

move your MySQL to 32 bit install and then re-install the gem with the
– --with-mysql-config=/usr/local/mysql/bin/mysql_config.

The added complication for me was that MySQL 64-bit seems to work with
Ruby 1.8.6 – I only saw problems after updating to 1.8.7.