Error 2003: Can't connect to MySQL Server on 'localhost' (10061)
I'm not sure what the issue is because I'm using Xampp to host my website projects. I was able to create and access a MySQL database in PHP...
Here is what my initialization code looks like:
- Code: Select all
// global declarations
MYSQL *mysql = NULL;
...
// initialize MySQL and connect to a database
mysql = mysql_init(NULL);
if(!mysql)
{
sprintf(text, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql));
MessageBox(NULL, text, "Fatal Error", NULL);
return false;
}
// attempt to connect to the trial
if(!mysql_real_connect(mysql, "localhost", "root", "", NULL, 3306, NULL, 0))
{
sprintf(text, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql));
MessageBox(NULL, text, "Fatal Error", NULL);
return false;
}
As you can see, I am using port 3306 to access MySQL. Is this what Xampp uses? I did some research, and it looks right.