richardbc Posted April 14, 2011 Share Posted April 14, 2011 httpd-2.2.17-win32-x86-openssl-0.9.8o php-5.3.6-Win32-VC9-x86 mysql-5.5.11-win32 PHP code: $dbcnx = mysql_connect('localhost','root','admin'); Error message: No connection could be made because the target machine actively refused it. I used mysql.exe -u root -p to verify that mysql is working and using the right username and password. Any ideas how to fix it? Thanks, Richard Quote Link to comment https://forums.phpfreaks.com/topic/233756-mysql_connect-returns-error-message/ Share on other sites More sharing options...
markjoe Posted April 14, 2011 Share Posted April 14, 2011 Looks like firewall or mysql config problem. check firewall settings, and mysql socket and port settings (my.cnf). Quote Link to comment https://forums.phpfreaks.com/topic/233756-mysql_connect-returns-error-message/#findComment-1201786 Share on other sites More sharing options...
richardbc Posted April 15, 2011 Author Share Posted April 15, 2011 I shut down Skype, Antivirus and Windows firewall and reinstalled MySql. I am still getting the error message. I cannot find my.cnf but checked my.ini. It shows that the socket is set to mysql. Can anyone help with this issue? Quote Link to comment https://forums.phpfreaks.com/topic/233756-mysql_connect-returns-error-message/#findComment-1201845 Share on other sites More sharing options...
markjoe Posted April 15, 2011 Share Posted April 15, 2011 Forgot it was named differently on Windows, but that's the same config file. I don't know what you mean by socket being set to mysql, but make sure the port is set to 3306. This is not a php coding problem, I'm not entirely sure it's a MySQL configuration problem. If the port checks out and you're certain you don't have a firewall issue, maybe look into permissions next. Make sure that Apache httpd is allowed to open a socket and MySQL is allowed to as well. Maybe try to telnet to localhost 3306 to make sure it is responding. I'm just throwing out guesses based on my minimal Windows server administration experience, figured they couldn't hurt. Quote Link to comment https://forums.phpfreaks.com/topic/233756-mysql_connect-returns-error-message/#findComment-1202177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.