MySQL Forums
Forum List  »  PHP

Failed to connect to MySQL: (2003) Can't connect to MySQL server on 'localhost' (10061)
Posted by: Jav Carr
Date: April 17, 2017 04:37PM

Hi,
I´m using MAMP with PHP and Mysql server
I get an error message when I try to open the database using php.
The error message is:
Failed to connect to MySQL: (2003) Can't connect to MySQL server on 'localhost' (10061)

And the php code used is:

<?php
$mysqli = new mysqli("localhost", "javier", "", "ejemplo");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";

?>

Can anyone help, please?
many thanks Jav

Options: ReplyQuote


Subject
Written By
Posted
Failed to connect to MySQL: (2003) Can't connect to MySQL server on 'localhost' (10061)
April 17, 2017 04:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.