MySQL permissions error when showing databases

MySQLpermissions

I was trying to install homebrew and very very stupidly did this:

sudo chown -R $USER /usr/local

The Homebrew instructions say to do this and I'm not much of a sysadmin so I took their word for it. Lesson learned (although I wouldn't really know how to test this…seems like an "undo" script would be super valuable here)

Anyway, what is done is done, but now I get this error:

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 548
Server version: 5.1.33 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)

I tried chown-ing back to root with no avail. Does anyone know how I can fix this without reinstalling mysql? Optionally, if I have to reinstall mysql, how can I dump my databases without access to the command line so I don't lose all of my data.

Thanks!

Best Answer

Find mysql's data directory, and chown that to MySQL's user (typically mysql:mysql)...