从外部域连接在线数据库

I'm setting up a remote access to external database (from another domain),

I tried to whitelist the IP address of the second domain in the first cpanel domain

$db1 = new PDO('mysql:host=ip1;dbname=database1','user1','password1', array(PDO::MYSQL_ATTR_INIT_COMMAND =>  "SET NAMES 'UTF8'")); 
$db2= new PDO('mysql:host=ip2;dbname=database2','user2','password2', array(PDO::MYSQL_ATTR_INIT_COMMAND =>  "SET NAMES 'UTF8'")); 

I except to connect the external database (database1) from the domaine 2 But I get this error :

Access denied for user "user2@'ip_domaine2'(using password: YES)