introduction screenshots faq forum blog modules components download
Please use the search function and/or read the FAQ first.

Go to Topic: PreviousNext
Go to: Message ListNew TopicSearchLog InPrint View

Can't connect to mysql using localhost



Posted by: yada_mike
June 19, 2010 05:29AM
When I try out my code below:

<?php

mysql_connect("localhost", "", "" ) or die(mysql_error());
echo "Connected to MySQL<br />";

?>

gives this warning:

"Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files (x86)\EasyPHP-5.3.2i\www\NewProject\filename.php on line 3"


Can somebody please tell me what I am doing wrong? I have tried many variations of the fields and they all fail to connect, and I can't seem to figure out what I'm doing incorrectly.

Thanks!
Options: ReplyQuote
Posted by: Daisy
June 19, 2010 05:40AM
I am trying hard to link mysql to database in php to no avail. I am getting this message, could anyone please help in fixing this matter? Thanks anyway:

Notice: Undefined variable: slect in C:\Program Files (x86)\EasyPHP-5.3.2i\www\TestQuery.php on line 13

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files (x86)\EasyPHP-5.3.2i\www\TestQuery.php on line 15

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files (x86)\EasyPHP-5.3.2i\www\TestQuery.php on line 15

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files (x86)\EasyPHP-5.3.2i\www\TestQuery.php on line 15
Options: ReplyQuote
Posted by: Thierry
June 21, 2010 11:53AM
Use 127.0.0.1 instead of localhost.

(or read the FAQ)
Options: ReplyQuote
Posted by: yada_mike
June 21, 2010 06:30PM
Now it says that access is denied... I've run it as admin, could this be due to a firewall issue?
Options: ReplyQuote
Posted by: man-rodr
June 24, 2010 02:50AM
Worked like a charm for me in Windows 7 Pro 64 bits!

If you don't wanna change 'localhost' to '127.0.0.1' in all your files, you can edit the 'hosts' file located at 'C:\Windows\System32\drivers\etc' in Windows, just uncomment the line that says "# 127.0.0.1 localhost".

Bye!
Options: ReplyQuote
Posted by: r0m
June 22, 2010 09:55PM
I had the same problem... I solved it with this (my instalation is fresh and do not modify anything in log files):

$hostname = "127.0.0.1";
$username = "root";
$password = "";
$database = "my_DB";

I hope it will help you
Options: ReplyQuote


Go to: Message ListSearchLog In
Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.