When I try to connect to my external server (which has allowed external connections) from my WAMP Server installation using this code:
const SERVER = 'xxx.xxx.xxx.xx'; // Redacted, the target servers IP
const PORT = 3306;
const DATABASE = 'xxx'; // Redacted
const USERNAME = 'xxx'; // Redacted
const PASSWORD = 'xxx'; // Redacted
const TIMEOUT = 5;
try
{
$pdo = new PDO('mysql:dbname=' . DATABASE . ';host=' . SERVER . ';port=' . PORT, USERNAME, PASSWORD, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_TIMEOUT => TIMEOUT));
}
catch (PDOException $e)
{
echo $e->getMessage();
}
I get the following error message:
SQLSTATE[HY000] [1045] Access denied for user 'main'@'xxx.xxx.xxx.xx' (using password: YES)
where the IP address is my external (not LAN) IP address instead of the one that I specified.
I have tried this code before and it worked without any problems, but now suddenly for reasons that remain unknown to me, it attempts to connect to my own IP and fails. What am I doing wrong?