I am trying to connect to the database using PDO with IP address as host, but I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user 'xxx'@'%' to database 'ddd'' in /Applications/MAMP/htdocs/iravin/testconnect.php:31 Stack trace: #0 /Applications/MAMP/htdocs/iravin/testconnect.php(31): PDO->__construct('mysql:host=162....', 'xxx', 'zzz') #1 {main} thrown in /Applications/MAMP/htdocs/iravin/testconnect.php on line 31
While if I used the dns "xxx.com" as host, it will work normally.
Here's my code for connection:
$con = new PDO('mysql:host=123.123.123.12;dbname=xxx', 'zzz', 'ccc');