MySQL : Cannot connect to database server

MySQLwindows-vista

I downloaded MySQL last week and I've been having a ton of problems getting things to work. I ended up reinstalling it and setting the port to 3307 because for some reason 3306 was greyed out. When I installed it I got an error that the server wasn't configured, but I was able to get a connection working just fine.

Now (a few days later) I'm trying to restart that connection and I keep getting this error:

Cannot Connect to Database Server – Your connection attempt failed for user 'root' from your host to server at 127.0.0.1:3306: Can't connect to MySQL server on '127.0.0.1' (10061).

I've tried adding exceptions to my firewall to ports 3306 and 3307 and running a new instance configuration wizard (which crashed when it tried to start a service). I'm really new to MySQL and could definitely use help! Thanks!

Best Answer

I've had that happen (on XP and 7), and the easiest way was to use WAMP or XAMPP. If those aren't options (all of these have worked for me at some point):

  • See if you can't just set the port for the connection request. You might just need mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password'); (not sure you're using PHP, but you can set the port on most language DB interfaces)
  • restart the MySQL service
  • use netstat -n to see if there are anything on those ports. It might be that MySQL is running on 3307 try that.
  • tasklist and see if MySQL is open twice. If it is, kill both instances and then restart the server.
  • use taskkill to kill MySQL. Open MySQL. repeat above step.

I always end this type of post in a similar manner -- The spectral wolf fears only fire. The Google maps team can no longer help you, but if you master the wolf, he will guide you. Godspeed.