Reputation: 5
I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1130] Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server' in /home/.../public_html/php/default.php:10 Stack trace: #0 /home/.../public_html/php/default.php(10): PDO->__construct('mysql:host=...', '...', '...') #1 /home/.../public_html/php/login-status.php(8): getDB() #2 {main} thrown in /home/.../public_html/php/default.php on line 10
I've tried using localhost buy that doesn't work as i'm using a web hosting provider and their MySQL server is external.
This is my code for accessing the db:
$dbHost = '...';
$db = '...';
$dbUser = '...';
$dbPass = '...';
$db = new PDO("mysql:host=$dbHost;dbname=$db;charset=utf8", $dbUser, $dbPass);
('...' is censored info)
Upvotes: 0
Views: 2399
Reputation: 24316
A few things:
1) Make sure you can connect to that port.
2) Make sure the connection string is correct for the specific type of database you are trying to reach
3) Ensure that your IP address is on the whitelist for allowed access, you wouldn't want the world to be able to connect to it.
Upvotes: 1