Error: uninitialized constant MysqlCompat::MysqlRes

I had this issue after upgrading from ubuntu 9.10 (karmic) to 10.4 (lucid). the solution was to libmysqlclient16-dev:

sudo aptitude install libmysqlclient16-dev

I am not sure of why this error is coming, but just for a moment, try rake db:create before doing rake db:migrate.

It might solve your problem.

Jatin kumar wrote:

I am not sure of why this error is coming, but just for a moment, try rake db:create before doing rake db:migrate. It might solve your problem.

The Mysql::Result constant is defined in the mysql_api gem (.so shared object) - this is located in gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.so

To fix the error the cleanest way I could think of - I created a symbolic link to this object in /usr/lib/ruby/1.9.1/ - which is in Ruby's $LOAD_PATH variable - which you can see your own version via : irb; puts "#{$LOAD_PATH}";

- None of the solutions people had posted on the web helped me - the main ones I kept seeing were - reinstall the mysql gem with ARCH_FLAGS set differently - and make a symbolic link mysql -> '.' because Ruby was looking one directory too deep

I'm using Ubuntu Karamic Koala, Ruby 1.9.1, mysql-2.8.1, rails-2.3.5

Leopard 10.6.4. Solved on my side by reinstalling mysql, using the 64bits version instead of the mistakenly installed 32bits. Obvious ?

Kyle Fox 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 Cullen <rails-mailing-l...@andreas-s.net>

Exactly the answer I needed. Thanks!

Kyle Fox 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 Cullen <rails-mailing-l...@andreas-s.net>

This fixed the problem for me. thanks!

-Jason

Thanks Kyle, worked awesomely on my macosx machine.

Kyle Fox wrote in post #846791:

Oren Golan wrote in post #923611:

I had this issue after upgrading from ubuntu 9.10 (karmic) to 10.4 (lucid). the solution was to libmysqlclient16-dev:

sudo aptitude install libmysqlclient16-dev

As a Ubuntu user that did the trick for me. Thanks a lot, Oren! Your decision to post this probably saved hours of work for me.

Raphael Petegrosso wrote in post #859937:

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 tried this and got the following message (also using Snow Leopard)

ERROR: While executing gem ... (Gem::CommandLineError)     Please specify at least one gem name (e.g. gem build GEMNAME)

Michael S. wrote in post #980959:

Raphael Petegrosso wrote in post #859937:

I tried this and got the following message (also using Snow Leopard)

ERROR: While executing gem ... (Gem::CommandLineError)     Please specify at least one gem name (e.g. gem build GEMNAME)

do :

sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundleruby