With a little side of applesauce...

Friday, August 17, 2012

macports - mysql socket causing '#2002 Cannot log in to the MySQL server'

I was trying to setup phpmyadmin on my Mac 10.7.4 with MacPorts and kept getting:
#2002 Cannot log in to the MySQL server

Here is how I fixed it:

1. find the MacPorts mysql5-server socket (mysql needs to be running):
speeves@mycomp:~/Documents/workspace/phpmyadmin$ netstat | grep mysql 
ffffff801826c2c0 stream      0      0 ffffff801dd0a1f0                0                0                0 /opt/local/var/run/mysql5/mysqld.sock
2. Add this line to /opt/local/etc/php5/php.ini:
mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock
3. Add this line to /path/to/webroot/phpmyadmin/config.inc.php
$cfg['Servers'][$i]['socket'] = '/opt/local/var/run/mysql5/mysqld.sock';
4. Restart Apache

No comments: