these errors usualy occur when mysqld ,httpd are not running
could not connect to localhost(port) means no one is listening at that port for your connection.
also see whether your username and password are required for your connection (in configuration file mysql.password=..,mysql.username=... and ServerName=...)
settings...