error: MySQL Cannot Connect to Database Server from MySQL-Workbench (windows 7)
I recently encountered the “Cannot Connect to Database Server” when attempting to connect to a local instance of MySQL via MySQL Workbench. A while ago I installed XAMPP to do some PHP MySQL development work yet now this connection error. The error says “Cannot Connect to Database Server, your connection attempt failed for user ‘root’ from your host to server at localhost:3306”.
MySQL Cannot Connect error
I immediately suspected the service was not running. It is possible to look for the service by clicking on the Start (windows) button, and right clicking Computer, then Manage. Expand to see Services and Applications. The look and locate the MySQL service and start it.
If you cannot find it, see if you have software on your windows machine that is used to run Apache, MySQL and PHP. Two common programs are WAMP and XAMPP.
Try to start-up the MySQL using the interface provided for XAMPP there is a control panel where you can simply start the service by clicking on the start button. Notice the port should show 3306.
starting the MySQL service with XAMPP control panel
Because PHP is so integrated with MySQL you will need the APACHE service started as well. If you find you have trouble like I did, see if you have any services that may interfere with running on port 80. In my case, I found the issue and fixed it by going into the windows services list and stopping the service “Web deployment Agent Service”. Also if you are running any Virtual Machine Software you may also have services that are already using port 80. Note, be prepared to stop any services again in the future. When you restart windows the problem may reappear because the services you stopped can be restarted automatically.