Tag Archives: mysql

Bundler, OSX and the MysqlCompat::MysqlRes error

If you get the uninitialized constant MysqlCompat::MysqlRes error when trying to run your Rails app all the evidence points to it being a 32 v 64 bit issue.  However, I had built mysql for the x86_64 architecture and the mysql gem installed was also for 64 bits.  So why was I still getting this error.  It turns out that bundler was building the mysql gem in 32 bits.  OSX Snow Leopard ships with Ruby in a universal binary containing the ppc, i386 and x86_64 binaries and for whatever reason bundle install was using the 32 bit ruby and re-building everything even though I had the gems already installed in the system in 64 bit mode.  This could be because the user doing the building was 1) unprivileged and 2) using bundle install \--path=vendor.  Maybe bundler was picking the first version of ruby that was appropriate to the platform.  However, doing bundle install \--deployment also had the same issues. I have no idea why it was rebuilding gems that already existed on my system. The way to get round it was to force bundler to build in 64 bits by using env ARCHFLAGS='-arch x86_64' bundle install --path=vendor
Maybe the best idea is not to use the Ruby that ships with OSX and build one appropriate to your environment in the first place.

Obscure mysql bug number 1153 (08S01) (my packet’s too big)

Ok, here’s one you don’t see every day.

Importing a mysql dumpfile results in “ERROR 1153 (08S01) at line 265: Got a packet bigger than ‘max_allowed_packet’ bytes”


Log in to a mysql console,

enter the magic commands:

set global net_buffer_length=1000000;

set global max_allowed_packet=1000000000;

Modify your import to include the command:


so you have something like

mysql –max_allowed_packet=100M -u user -p db_name < dump.sql

Try again

Your mileage may vary ( do they say kilometerage elsewhere?) so increase the allowed sizes if you have to.

Getting data out of MySQL (and then back in)

There seems to be lots of ways to get your databases out of a MySQL database and an even more bewildering array of ways to get it back in.  I have found that the following commands seem to be the best way to do it (for me):


mysqldump –databases database_name -u username -p > dumpfile.sql


mysql -u username -p database_name < dumpfile.sql

Find the reference here.

15/02/10: Here is another variation on getting stuff out:

mysqldump db_name table1 table2 table3 -u username -p > dumpfile.sql