Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

MAMP/MYSQLI Error: Warning: mysqli::__construct(): (HY000/2003): Can't connect to MySQL server on 'localhost' (10061)

This problem is occurring using MAMP on Windows 10.

I have no problem connecting to Apache or PHPMyAdmin. However, when I enter the URL of my database connection file through PHP (http://localhost:8888/php_tag_cloud/database/open_db.php), I get the above error message in the title. Simply changing the port numbers through MAMP as many have suggested does not work. Neither does uninstall and then reinstalling MAMP.

Admittedly, this error occurred when trying to organize some files (by deleting a few I thought to be unnecessary). It seems I have made things worse.

I didn't mention the location of the error above in the title so here it is:

C:\MAMP\htdocs\php_tag_cloud\database\open_db.php on line 9

Line 9 would be this here:

$mysqli = new mysqli($server_name, $username, $password, $db); 

And here is all the code for the database connection file the error occurs in:

    $server_name = "localhost";
    $username = "root";
    $password = "";
    $db = "tagcloud";

$mysqli = new mysqli($server_name, $username, $password, $db); 

There are solutions for this particular error but they refer to XAAMP or files that either do not exist in my directory or I cannot find (and I've searched hard).

Edit: The duplicate above does not contain the answer, the corresponding error message, and I am not using Laravel.

Comments