Help me recover a deleted MySQL database on osx
December 4, 2009 10:19 AM   Subscribe

Where does MySQL store actual data in Snow Leopard? How would I retrieve a deleted database from a Time Machine backup?

MySQL was crashing repeatedly on my Snow Leopard. On the advice of an Apple genius, I nuked the existing install and all its associated directories. I didn't worry much because I do database stuff on my work computer and only keep copies on my laptop.

Turns out that there was one particular database [now nuked] that I spent a whole week cleaning up on my laptop. The desktop only has a really old version of this particular database.

I have regular time machine backups. How do I pluck this database out and restore it?
I cannot for the life of me figure out how to get to the data without going through mysql. Someone suggested looking in /usr/local/mysql/data

I can get to the mysql directory but have no permission to enter the data directory. I could recreate much of this work but it will take forever and I'd rather not. Can someone help?
posted by special-k to Computers & Internet (5 answers total) 1 user marked this as a favorite
If you are an admin user on this machine, try the command:

sudo chmod o+rX /usr/local/mysql/data

This will allow all users to read and search directories beneath the MySQL directory.
posted by mkb at 10:23 AM on December 4, 2009

mkb's way works. For completeness, I believe you can also go in as root:
sudo su
... and enter your password. Then you can rummage around in the data/ directory.
posted by krilli at 10:47 AM on December 4, 2009

I think the recommended way to get a root shell under Mac OS X is "sudo -s" but honestly I'm not terribly sure what the difference is.
posted by mkb at 1:26 PM on December 4, 2009 [1 favorite]

Hm, thanks, usually if some method of doing root-y things is recommended over the other, it's 'coz of security :) ... so thanks! Gonna have a look at that.
posted by krilli at 6:10 PM on December 4, 2009

"I think the recommended way to get a root shell under Mac OS X is "sudo -s" but honestly I'm not terribly sure what the difference is."

'sudo su' first changes your $ENV as specified by the configuration in /etc/sudoers, then redefines your path to be "/sbin:/bin:/usr/sbin:/usr/bin" and switches you to root a second time (sudo already made you root first). 'sudo -s' is pretty much just a shorthand for 'sudo $SHELL', it invokes your default shell as root after making any ENV changes specified by the sudoers file.

tg;dr - sudo and su solve the same problem, using them both at once is brittle and overengineered.
posted by idiopath at 9:27 AM on December 5, 2009

« Older Who are the world's 50 most famous/recognizable...   |   Any difference for renting a car in Toronto if you... Newer »
This thread is closed to new comments.