May 312009
 

Make a quick dump of a mysql database:

mysql_dump db_name > backup-file.sql

You can then read that dump file back into the server like this

mysql db_name < backup-file.sql

or like this:

mysql -e “source /path/to/backup/backup-file.sql” db_name
 Posted by at 8:43 pm  Tagged with:
Mar 072009
 

First, isntall MySQL package installer from

http://dev.mysql.com/downloads/mysql/5.1.html#downloads

DON’T DOWNLOAD THE 64-BIT VERSION!!!
You must download the 32-bit version even if you have a 64-bit machine.

Then I was able to run this. Note: it is important to give the gem installer the -with-mysql-config flag, and point it to the file mysql_config inside the bin/ directory

sudo gem install mysql – -with-mysql-config=/usr/local/mysql/bin/mysql_config

UPDATE: Me thinks the 64-bit version now works with Snow Leopard 10.6 (haven’t tested under 10.5). But you have to set the flags to use 64-bit:

Prior to Leopard:
sudo gem install mysql – -with-mysql-dir=/usr/local/mysql

Leopard on a PPC machine:
sudo env ARCHFLAGS=”-arch ppc” gem install mysql – -with-mysql-config=/usr/local/mysql/bin/mysql_config

Leopard on an Intel machine:
sudo env ARCHFLAGS=”-arch i386″ gem install mysql – -with-mysql-config=/usr/local/mysql/bin/mysql_config

Snow Leopard (only on Intel):
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql – -with-mysql-config=/usr/local/mysql/bin/mysql_config

If you don’t run this with the right architecture RCHFLAGS, you get this when you try to launch your app:

unitialized constant MysqlCompat::MysqlRes

http://techliberty.blogspot.com/2009/12/dealing-with-rake-aborted-uninitialized.html
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard
http://stackoverflow.com/questions/991708/rails-mysql-and-snow-leopard

I had a real hard time with this one on a recent Snow Leopard upgrade, be sure to rebuild all your port installs too:
http://trac.macports.org/wiki/Migration

And finally do this:

cd /tmp
wget http://www.tmtm.org/en/ruby/mysql/ruby-mysql-0.2.6.tar.gz
tar xvfz ruby-mysql-0.2.6.tar.gz
cd ruby-mysql-0.2.6
sudo ruby install.rb