# Error: uninitialized constant MysqlCompat::MysqlRes

**URL:** <https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038>\
**Category:** Rails\
**Created:** [July 31, 2009, 9:00pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038 "2009-07-31T21:00:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [July 31, 2009, 9:00pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/1 "2009-07-31T21:00:40Z")

</div>

Hi,  
I installed the “kwatch-mysql-ruby” gem on my Debian server but when I  
try to run the “db:migrate” task I get the following error:

\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate  
rake aborted!  
uninitialized constant MysqlCompat::MysqlRes  
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active\_support/dependencies.rb:440:in  
`rescue in load_missing_constant' /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:436:in`load\_missing\_constant’  
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active\_support/dependencies.rb:80:in  
`const_missing_with_dependencies' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:9:in`define\_all\_hashes\_method!’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:71:in  
`mysql_connection' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in`new\_connection’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:245:in  
`checkout_new_connection' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in`block (2 levels) in checkout’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:184:in  
`loop' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in`block in checkout’  
/usr/local/lib/ruby/1.9.1/monitor.rb:190:in `mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in`checkout’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:98:in  
`connection' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in`retrieve\_connection’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:123:in  
`retrieve_connection' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in`connection’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/migration.rb:435:in  
`initialize' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/migration.rb:400:in`new’  
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active\_record/migration.rb:400:in  
`up' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/migration.rb:383:in`migrate’  
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/tasks/databases.rake:116:in  
`block (2 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in`call’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in`each’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in  
`execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in`block  
in invoke\_with\_call\_chain’  
/usr/local/lib/ruby/1.9.1/monitor.rb:190:in `mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in`invoke\_with\_call\_chain’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in  
`invoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in`invoke\_task’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in  
`block (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in`each’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in  
`block in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in`standard\_exception\_handling’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in  
`top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in`block in run’  
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in  
`standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in`run’  
/usr/local/bin/rake:31:in `’

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [August 25, 2009, 12:10am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/2 "2009-08-25T00:10:40Z")

</div>

Hi there,

I just started using aptana and am working on my HelloWorld, but I’m  
gettin the same error “uninitialized constant MysqlCompat::MysqlRes”.  
Did you ever figure out what is it about?

Thanks!

On Jul 31, 12:00 pm, “Martin J.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [August 27, 2009, 8:07pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/3 "2009-08-27T20:07:11Z")

</div>

Martin J. wrote:

> Hi,  
> I installed the “kwatch-mysql-ruby” gem on my Debian server but when I  
> try to run the “db:migrate” task I get the following error:
> 
> \*\* Invoke db:migrate (first\_time)  
> \*\* Invoke environment (first\_time)  
> \*\* Execute environment  
> \*\* Execute db:migrate  
> rake aborted!  
> uninitialized constant MysqlCompat::MysqlRes

I saw this, having freshly installed Rails 2.3.3, and then being told to  
run ‘gem install mysql’ because the MySQL client is no longer bundled  
with Rails, as of 2.2

Okay, I did that. Then I got the error message you showed in your post  
– about MysqlCompat::MysqlRes not being defined.

Turns out there is no such thing; this error is caused by a malfunction  
of the mysql-2.8.1 gem.

If you install the gem by hand, chances are when you run the test you’ll  
find that the gem’s bundle doesn’t actually manage to load the  
mysqlclient library. (On my MacOS X 10.5.8 system, it’s a .dylib; under  
Linux it may be a .so)

The error message I saw during the test phase looked like this:

./mysql.bundle: dlopen(./mysql.bundle, 9): Library not loaded:  
/usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (LoadError)  
Referenced from:  
/Users/ccullen/Projects/npapp-v2/mysql-ruby-2.8.1/mysql.bundle  
Reason: image not found - ./mysql.bundle  
from test.rb:5

From that message you can see it’s looking for the mysqlclient library  
in a directory one level too deep, vis-a-vis the location my libraries  
occupy:  
/usr/local/mysql/lib is right; /usr/local/mysql/lib/mysql is not.

It is however pretty simple to create a ‘mysql’ symlink inside  
/usr/local/mysql/lib and point it at ‘.’, allowing the broken  
mysql.bundle to locate its libraries.

This is definitely a hack. I just wanted to help, since I haven’t seen  
any answers posted, and certainly nothing to explain why this error is  
occurring.

Best of luck!

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [September 19, 2009, 11:15pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/4 "2009-09-19T23:15:59Z")

</div>

This didn’t seem to fix the error for me. I still get ‘uninitialized  
constant MysqlCompat::MysqlRes’

Kyle F. wrote:

> To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:
> 
> sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
> config=/usr/local/mysql/bin/mysql\_config
> 
> On Aug 27, 12:07ï¿½pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

cheers,

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [August 29, 2009, 12:56am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/5 "2009-08-29T00:56:10Z")

</div>

To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:

sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
config=/usr/local/mysql/bin/mysql\_config

On Aug 27, 12:07 pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [September 29, 2009, 3:59pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/6 "2009-09-29T15:59:39Z")

</div>

I also built the gem with the archflags, but am still getting this  
error. Did anyone find a different reason that might be causing this?

On Sep 19, 11:15 pm, Evan G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [September 29, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/7 "2009-09-29T21:42:44Z")

</div>

Evan G. wrote:

> This didn’t seem to fix the error for me. I still get ‘uninitialized  
> constant MysqlCompat::MysqlRes’
> 
> Kyle F. wrote:
> 
> > To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:
> > 
> > sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
> > config=/usr/local/mysql/bin/mysql\_config
> > 
> > On Aug 27, 12:07ï¿½pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> cheers,

on my Centos Machine, i had to install mysql-devel.x86\_64 first, then i  
ran the command:

env ARCHFLAGS=“-arch x86\_64” gem install mysql –  
–with-mysql-config=/usr/lib64/mysql/mysql\_config

which did the trick.

thanks Kyle

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [September 30, 2009, 6:36am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/8 "2009-09-30T06:36:38Z")

</div>

Anybody still has the issue?

I have been using jruby for a while but today I was trying to setup  
using the last version of ruby 1.9 and rails 2.3.4 and I got hit with  
that.

Also running centos and tried the ARCHFLAGS trick with no success.

Pishty Ags wrote:

> Evan G. wrote:
> 
> > This didn’t seem to fix the error for me. I still get ‘uninitialized  
> > constant MysqlCompat::MysqlRes’
> > 
> > Kyle F. wrote:
> > 
> > > To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:
> > > 
> > > sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
> > > config=/usr/local/mysql/bin/mysql\_config
> > > 
> > > On Aug 27, 12:07ï¿½pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> > 
> > cheers,
> 
> on my Centos Machine, i had to install mysql-devel.x86\_64 first, then i  
> ran the command:
> 
> env ARCHFLAGS=“-arch x86\_64” gem install mysql –  
> –with-mysql-config=/usr/lib64/mysql/mysql\_config
> 
> which did the trick.
> 
> thanks Kyle

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [September 30, 2009, 6:46am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/9 "2009-09-30T06:46:09Z")

</div>

Actually, doing more research and an strace on the process I found the  
problem.

Looking in the wrong place for the location of the library, I added my  
mysql lib directory to ld.so.conf/mysql.conf config file and it fixed  
it.

Jean Bombeur wrote:

> Anybody still has the issue?
> 
> I have been using jruby for a while but today I was trying to setup  
> using the last version of ruby 1.9 and rails 2.3.4 and I got hit with  
> that.
> 
> Also running centos and tried the ARCHFLAGS trick with no success.
> 
> Pishty Ags wrote:
> 
> > Evan G. wrote:
> > 
> > > This didn’t seem to fix the error for me. I still get ‘uninitialized  
> > > constant MysqlCompat::MysqlRes’
> > > 
> > > Kyle F. wrote:
> > > 
> > > > To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:
> > > > 
> > > > sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
> > > > config=/usr/local/mysql/bin/mysql\_config
> > > > 
> > > > On Aug 27, 12:07ï¿½pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> > > 
> > > cheers,
> > 
> > on my Centos Machine, i had to install mysql-devel.x86\_64 first, then i  
> > ran the command:
> > 
> > env ARCHFLAGS=“-arch x86\_64” gem install mysql –  
> > –with-mysql-config=/usr/lib64/mysql/mysql\_config
> > 
> > which did the trick.
> > 
> > thanks Kyle

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 16, 2009, 1:54am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/10 "2009-10-16T01:54:56Z")

</div>

I was having the same problem on Snow Leopard and, after some time I  
did the following:

Removed all mysql gems I had:

gem uninstall mysql

In my case I had to specify both mysql-dir and mysql-config (and -arch  
x86\_64 to 64 bits)

export ARCHFLAGS="-arch i386 -arch x86\_64" ; gem install --no-rdoc –  
no-ri mysql – --with-mysql-dir=/usr/local --with-mysql-config=/usr/  
local/mysql/bin/mysql\_config

Hope it works

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 16, 2009, 8:43am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/11 "2009-10-16T08:43:55Z")

</div>

Raphael Petegrosso wrote:

> I was having the same problem on Snow Leopard and, after some time I  
> did the following:
> 
> Removed all mysql gems I had:
> 
> gem uninstall mysql
> 
> In my case I had to specify both mysql-dir and mysql-config (and -arch  
> x86\_64 to 64 bits)
> 
> export ARCHFLAGS="-arch i386 -arch x86\_64" ; gem install --no-rdoc –  
> no-ri mysql – --with-mysql-dir=/usr/local --with-mysql-config=/usr/  
> local/mysql/bin/mysql\_config
> 
> Hope it works

I was able to resolve this issue. Thanks for your valuable suggestions.  
Along with the above steps, I had to configure the LD\_LIBRARY\_PATH.

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 22, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/12 "2009-10-22T16:26:24Z")

</div>

These instructions also worked for me after upgrading to Snow Leopard.  
In my case mysql was in /opt/local/lib/mysql5, so the following fixed it  
for me:

sudo gem uninstall mysql

export ARCHFLAGS="-arch i386 -arch x86\_64" ; gem install --no-rdoc  
–no-ri mysql – --with-mysql-dir=/opt/local/lib/mysql5  
–with-mysql-config=/opt/local/lib/mysql5/bin/mysql\_config

> I was having the same problem on Snow Leopard and, after some time I  
> did the following:
> 
> Removed all mysql gems I had:
> 
> gem uninstall mysql
> 
> In my case I had to specify both mysql-dir and mysql-config (and -arch  
> x86\_64 to 64 bits)
> 
> export ARCHFLAGS="-arch i386 -arch x86\_64" ; gem install --no-rdoc –  
> no-ri mysql – --with-mysql-dir=/usr/local --with-mysql-config=/usr/  
> local/mysql/bin/mysql\_config
> 
> Hope it works

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 22, 2009, 5:33pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/13 "2009-10-22T17:33:42Z")

</div>

Andrew McDonough wrote:

> These instructions also worked for me after upgrading to Snow Leopard.  
> In my case mysql was in /opt/local/lib/mysql5, so the following fixed it  
> for me:
> 
> sudo gem uninstall mysql
> 
> export ARCHFLAGS="-arch i386 -arch x86\_64" ; gem install --no-rdoc  
> –no-ri mysql – --with-mysql-dir=/opt/local/lib/mysql5  
> –with-mysql-config=/opt/local/lib/mysql5/bin/mysql\_config

I was able to get the mysql gem to compile by doing something like that;  
but then I found that, for whatever reason, /tmp/mysql.sock did not  
exist (and so my rake tasks failed, etc). I followed instructions on  
the Rails blog to install MySQL from a DMG, and then /tmp/mysql.sock  
existed as expected.

HTH.

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 24, 2009, 3:03pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/14 "2009-10-24T15:03:53Z")

</div>

had the same, switching to 2.7 helps  
sudo gem install mysql -v 2.7

On 22 Okt., 17:33, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [October 13, 2009, 2:17am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/15 "2009-10-13T02:17:44Z")

</div>

Hi

\*\*\*\*\*\*\*\*\*\*\*\*\* URGENT PLEASEEEEEEEEEEEEEEEEEEEEEEEEEE \*\*\*\*\*\*\*\*\*\*\*  
I still see the problem after following the above steps.  
Please please help me.

~Sam.

# ============================================================================== ruby script/server =\> Booting Mongrel =\> Rails 2.3.4 application starting on [http://0.0.0.0:3000](http://0.0.0.0:3000) =\> Call with -d to detach =\> Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon Oct 12 17:15:15 -0700 2009 Status: 500 Internal Server Error uninitialized constant MysqlCompat::MysqlRes /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active\_support/dep endencies.rb:440:in `load_missing_constant' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dep endencies.rb:80:in `const\_missing’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/mysql\_adapter.rb:9:in `define_all_hashes_method!' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/mysql_adapter.rb:66:in `mysql\_connection’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_pool.rb:223:in `send' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_pool.rb:223:in `new\_connection’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_pool.rb:245:in `checkout_new_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_pool.rb:188:in `checkout’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_pool.rb:184:in `loop' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_pool.rb:184:in `checkout’ /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_pool.rb:183:in `checkout’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_pool.rb:98:in `connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_pool.rb:326:in `retrieve\_connection’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_specification.rb:123:in `retrieve_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conne ction_adapters/abstract/connection_specification.rb:115:in `connection’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/query \_cache.rb:9:in `cache' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query _cache.rb:28:in `call’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/conne ction\_adapters/abstract/connection\_pool.rb:361:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/fai lsafe.rb:26:in `call’ /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchro nize’ /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dis patcher.rb:114:in `call’ /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action\_controller/rel oader.rb:34:in `run' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dis patcher.rb:108:in `call’ /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call’ /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call’ /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log\_tailer.rb:1 7:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:i n `call’ /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in `call ' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61: in `process’ /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `proce ss_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each’ /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `proce ss_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run’ /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285

Jean Bombeur wrote:

> Actually, doing more research and an strace on the process I found the  
> problem.
> 
> Looking in the wrong place for the location of the library, I added my  
> mysql lib directory to ld.so.conf/mysql.conf config file and it fixed  
> it.
> 
> Jean Bombeur wrote:
> 
> > Anybody still has the issue?
> > 
> > I have been using jruby for a while but today I was trying to setup  
> > using the last version of ruby 1.9 and rails 2.3.4 and I got hit with  
> > that.
> > 
> > Also running centos and tried the ARCHFLAGS trick with no success.
> > 
> > Pishty Ags wrote:
> > 
> > > Evan G. wrote:
> > > 
> > > > This didn’t seem to fix the error for me. I still get ‘uninitialized  
> > > > constant MysqlCompat::MysqlRes’
> > > > 
> > > > Kyle F. wrote:
> > > > 
> > > > > To fix this, specify ARCHFLAGS when you install the ‘mysql’ gem:
> > > > > 
> > > > > sudo env ARCHFLAGS=“-arch x86\_64” gem install mysql – --with-mysql-  
> > > > > config=/usr/local/mysql/bin/mysql\_config
> > > > > 
> > > > > On Aug 27, 12:07ï¿½pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> > > > 
> > > > cheers,
> > > 
> > > on my Centos Machine, i had to install mysql-devel.x86\_64 first, then i  
> > > ran the command:
> > > 
> > > env ARCHFLAGS=“-arch x86\_64” gem install mysql –  
> > > –with-mysql-config=/usr/lib64/mysql/mysql\_config
> > > 
> > > which did the trick.
> > > 
> > > thanks Kyle

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [November 11, 2009, 8:12pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/16 "2009-11-11T20:12:06Z")

</div>

grosser.michael wrote:

> had the same, switching to 2.7 helps  
> sudo gem install mysql -v 2.7
> 
> On 22 Okt., 17:33, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> I was able to install the mysql v. 2.7 gem on a macport mysql version  
> with:

sudo gem install -v 2.7 --no-rdoc --no-ri mysql –  
–with-mysql-dir=/opt/local/lib/mysql5  
–with-mysql-config=/opt/local/lib/mysql5/bin/mysql\_config;

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [December 16, 2009, 11:26pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/17 "2009-12-16T23:26:48Z")

</div>

Steven Hampton wrote:

> If you are still getting this issue, I have posted an EXPLANATION as  
> well as how to derive the correct solution for your system here  
> [http://techliberty.blogspot.com/](http://techliberty.blogspot.com/) the EXPLANATION was to long for a forum  
> post 🙂

Thanks a lot Steven. I am not seeing this issue now, but will definitely  
go through your explanation…!!!

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [December 16, 2009, 7:49pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/18 "2009-12-16T19:49:02Z")

</div>

If you are still getting this issue, I have posted an EXPLANATION as  
well as how to derive the correct solution for your system here  
[http://techliberty.blogspot.com/](http://techliberty.blogspot.com/) the EXPLANATION was to long for a forum  
post 🙂

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [December 26, 2009, 4:11pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/19 "2009-12-26T16:11:58Z")

</div>

This article got it done for me:

> <https://stackoverflow.com/questions/991708/rails-mysql-and-snow-leopard>

---

<div class="post-metadata">

**Author:** ![martin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@martin](https://www.ruby-forum.com/u/martin)\
**Post date:** [January 22, 2010, 6:35am UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038/20 "2010-01-22T06:35:38Z")

</div>

Caleb

Could I ask what test you were running during the “test phase” you  
mention below?

I’m really stumped by my problems with this bug, and am trying to  
determine if my error has the same cause.

thanks,  
Rick

Caleb C. wrote:

> Martin J. wrote:
> 
> > Hi,  
> > I installed the “kwatch-mysql-ruby” gem on my Debian server but when I  
> > try to run the “db:migrate” task I get the following error:
> > 
> > \*\* Invoke db:migrate (first\_time)  
> > \*\* Invoke environment (first\_time)  
> > \*\* Execute environment  
> > \*\* Execute db:migrate  
> > rake aborted!  
> > uninitialized constant MysqlCompat::MysqlRes
> 
> I saw this, having freshly installed Rails 2.3.3, and then being told to  
> run ‘gem install mysql’ because the MySQL client is no longer bundled  
> with Rails, as of 2.2
> 
> Okay, I did that. Then I got the error message you showed in your post  
> – about MysqlCompat::MysqlRes not being defined.
> 
> Turns out there is no such thing; this error is caused by a malfunction  
> of the mysql-2.8.1 gem.
> 
> If you install the gem by hand, chances are when you run the test you’ll  
> find that the gem’s bundle doesn’t actually manage to load the  
> mysqlclient library. (On my MacOS X 10.5.8 system, it’s a .dylib; under  
> Linux it may be a .so)
> 
> The error message I saw during the test phase looked like this:
> 
> ./mysql.bundle: dlopen(./mysql.bundle, 9): Library not loaded:  
> /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib (LoadError)  
> Referenced from:  
> /Users/ccullen/Projects/npapp-v2/mysql-ruby-2.8.1/mysql.bundle  
> Reason: image not found - ./mysql.bundle  
> from test.rb:5
> 
> From that message you can see it’s looking for the mysqlclient library  
> in a directory one level too deep, vis-a-vis the location my libraries  
> occupy:  
> /usr/local/mysql/lib is right; /usr/local/mysql/lib/mysql is not.
> 
> It is however pretty simple to create a ‘mysql’ symlink inside  
> /usr/local/mysql/lib and point it at ‘.’, allowing the broken  
> mysql.bundle to locate its libraries.
> 
> This is definitely a hack. I just wanted to help, since I haven’t seen  
> any answers posted, and certainly nothing to explain why this error is  
> occurring.
> 
> Best of luck!

[Next page](https://www.ruby-forum.com/t/error-uninitialized-constant-mysqlcompat-mysqlres/173038.md?page=2)
