views:

42

answers:

2

I first installed Macports so it would be easier. Then installed mysql5,mysql5-server and py26-mysql.

Everything went ok. When I typed: which mysql5 it returns `/opt/local/bin/mysql5

But when i try to enter the server: mysql5, an error is generated:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

How do I fix it?

I eventually wish to use mysql as a backend to a django project. `

A: 

Make sure mysqld (mysql daemon) is actually running on your Mac.

Remember: MySQL is a SQLServer, so it needs a daemon, probably listening on some TCP port to process client's requests.

To check if MySQL daemon is running, type into a terminal session:

$ ps aux | grep mysql

And mysql daemon process should be printed.

If it is not running, start it as stated by Mac Ports documentation.

Pablo Santa Cruz
+1  A: 

You need to start the server. You should be able to run:

sudo /opt/local/share/mysql5/mysql/mysql.server start

You can set it to run on boot with:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

There is a useful guide with other details.

Matthew Flaschen