Friday, August 19, 2011

MySQL Nightmare

So I was trying to set up a local MySQL server through MacPorts following this post and I ran into quite a few problems.

Initially I couldn't get MySQL to run when I ran the following command
sudo /opt/local/lib/mysql5/bin/mysqld_safe &

It would act like it was working and then about 10 seconds later, PID ended. WTF. CONSULT THE ERROR LOGS

[ERROR] Can't start server : Bind on unix socket: Permission denied

Okay, so then I ran through checking permissions on the data directory of the mysql installation (located at /opt/local/var/db/mysql5) and it all seemed to be fine but it still wouldn't run! I finally, after copying the my.cnf file...

sudo cp /opt/local/share/mysql5/mysql/my-medium.cnf /opt/local/etc/mysql5/my.cnf

I changed the 'socket' field in my.cnf to simply /tmp/mysqld.sock for both the client and server. The permissions seemed to work fine, finally. It would now instantly stop the pid after I started running the server, and I consulted the error logs

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

Uh, what? This is evidently a table that should be generated during installation. So, because I didn't have any tables to back up, I went ahead and re ran the install

sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

And BOOM. It worked. This is on Mac OS X Lion 10.7

Now it's time to try and set up php and apache and make them all work in harmony. Mmm.

2 comments:

Dianne Baer said...

You may need to write that in English for your mom to understand. Geez! =)

Mojave Storm said...

haha, I would but I generally meant that for me if I have any problems in the future :) So I don't waste... a 100 hours on it