I am using php5 and mysql 5
I am getting the following error while connecting the both:
Can't connect to MySQL server on 'localhost' (10061)
Can anyone tell the solution???
I am using php5 and mysql 5
I am getting the following error while connecting the both:
Can't connect to MySQL server on 'localhost' (10061)
Can anyone tell the solution???
Perhaps you did not start the MySQL server?
If you are talking about MYSQL service then its started and working.
Then how do i connect php with mysql???
maano wrote:its started and working.
How do you know?
[FONT="Verdana"]Assuming your local server (Apache, whatever) is running:
[FONT="Arial"]$conn = mysql_connect("localhost", USER_NAME, PASS_WORD) or die ("Couldn't connect to local host.");[/FONT]
You can then select whatever database you want with:
[FONT="Arial"]$db = mysql_select_db($db_name, $conn) or die ("Couldn't select local database -- $db_name");[/FONT]
[FONT="Comic Sans MS"]HTH[/FONT]
[/FONT]
I am using php5 and mysql 5
While working through console mysql is working fine.
I am getting the following error while connecting the both through code mysql_connect:
Can't connect to MySQL server on 'localhost' (10061)
Can anyone tell the solution???
maano wrote:I am using php5 and mysql 5
While working through console mysql is working fine.I am getting the following error while connecting the both through code mysql_connect:
Can't connect to MySQL server on 'localhost' (10061)
Can anyone tell the solution???
[FONT="Verdana"]
Could you post some code please? Show us how you are programatically trying to connect to your DB.
[/FONT]
I have tried phpMyAdmin and i am able to work on mySQL with it. But still mu code it unable to connect to mySQL.
I am using the following code to connect:
<?php
$link = @mysql_connect('localhost', 'root', 'admin');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
@mysql_select_db('test', $link);
$sql = 'SELECT * FROM employee
LIMIT 0, 10 ';
$dataset = @($sql, $connection);
mysql_close($link);
?>
According to http://dev.mysql.com/doc/refman/5.0/en/can-not-connect-to-server.html:
[indent]The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, the network port you specified is the one configured on the server, and that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.[/indent]
You may want to read the above link and work your way through its trouble-shooting suggestions.
When i telnet 3307 (the port for mySQL) it connects for a few seconds and then displays "Connection to host lost".
I guess this might be causing the problem. Whay should i do?
You could try uninstalling MySQL and re-installing it using the guided wizard.
Did you ensure that the MySQL service was started first?
Yes mySQL service is started.
Problem not solved