Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have several databases I set up using mamp. Recently, my mac died of old age and I got a new one. Fortunately I have a made of bootable backup of my hard drive every day. Unfortunately, I cannot boot off of it with my new mac - the image is os x tiger and the new mac won't run tiger, only os x lion.

The upshot is, I have several mysql databases on that backup disk that I need to move to my new machine. Is there a way of doing this using my current setup running mamp under lion, perhaps open the databases on the backup disk, export the databases and then restarting mamp from the lion databases, and importing what was exported, or something?

Thanks for any ideas!

share|improve this question
    
Am I right to assume you have been able to mount the image and can see the mysql files? –  Jack Douglas Dec 30 '11 at 17:43
add comment

migrated from stackoverflow.com Dec 30 '11 at 17:40

This question came from our site for professional and enthusiast programmers.

1 Answer

On a mac, your MySQL installation is located in:

/usr/local/mysql/

This is the folder structure:

$ ls -lah /usr/local/mysql/
total 64
drwxr-xr-x  16 root    wheel   544B Nov 13 15:54 .
drwxrwxr-x  27 root    admin   918B Nov 24 11:42 ..
-rw-r--r--   1 root    wheel    18K Nov 13 15:47 COPYING
-rw-r--r--   1 root    wheel   7.2K Nov 13 15:47 INSTALL-BINARY
-rw-r--r--   1 root    wheel   2.5K Nov 13 15:47 README
drwxr-xr-x  46 root    wheel   1.5K Nov 13 15:54 bin
drwxr-xr-x  18 _mysql  wheel   612B Apr 27 13:37 data
drwxr-xr-x   6 root    wheel   204B Nov 13 15:54 docs
drwxr-xr-x  37 root    wheel   1.2K Nov 13 15:54 include
drwxr-xr-x  12 root    wheel   408B Nov 23 08:58 lib
drwxr-xr-x   5 root    wheel   170B Apr 25 06:48 man
drwxr-xr-x  19 root    wheel   646B Nov 23 08:58 mysql-test
drwxr-xr-x   3 root    wheel   102B Nov 13 15:54 scripts
drwxr-xr-x  32 root    wheel   1.1K Nov 13 15:54 share
drwxr-xr-x  28 root    wheel   952B Nov 13 15:54 sql-bench
drwxr-xr-x  16 root    wheel   544B Nov 13 15:54 support-files

You probably want to copy all of it to your local disk, then install MySQL from a disk image (DMG), backup the installed data folder, copy your backed up data folder contents into /usr/local/mysql/data, permission the folder to mysql, start mysqld and do an mysql_upgrade.

install mysql server from DMG... then...

 sudo mv /usr/local/mysql/data /usr/local/mysql/data_ORIG
 sudo cp /mybackupfolder/mysql/data /usr/local/mysql/data
 sudo chown -Rf mysql:wheel /usr/local/mysql/data
 sudo su -
 nohup /usr/local/mysql/bin/mysqld_safe &
 exit
 /usr/local/mysql/bin/mysql_upgrade -u root -p
 # read output

*Note: if you have a my.cnf, mv it to /etc/my.cnf.ORIG before you start mysqld.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.