Fixing MacPort’s MySQL5 install

I had to reinstall OSX the other day as certain applications were crashing with alarming frequency. As I’ve installed DarwinPorts(now called MacPorts) for managing my software development libraries, I reinstalled the usual application via port install app. Now everything went pretty smoothly, Rails, Apache2, Lighttpd, MySQL and PHP4 were all installed without much hassle.

But when I tried to login as root to the MySQL daemon, I kept getting a “Access denied for user ‘root’@’localhost’ (using password: YES)” error message. The odd thing was that I did not set a password for the root account during installation. Some searching on the internet suggested resetting the root password. However, that didn’t work, nor did reinstalling MySQL.

The issue was finally solved after following the suggestion from Abel Lopez from the comments sections of this page in the MySQL documentation. It turns out that the mysql user which owns the processes spawned from MySQL daemon didn’t have enough privileges for the data directory. The workaround was to remove /opt/local/var/db/mysql5/, recreate it and set its ownership via chown mysql:mysql.

After this was done, I re-ran the database install script and sure enough, I was able to login as root and change the password as well.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s