Hello,
i do it below:
======================================================
When connecting to a MySQL database on a given server from a different server, replace "localhost" with the IP address of the machine running the MySQL database.
In the MySQL section in Cpanel, you'd need to add the IP of the machine from which you want to access the database in the "Access hosts" section.
To give an example:
Server A with IP address 123.123.123.123 is running a MySQL database
Server B with IP address 231.231.231.231 wants to access the MySQL database on server A.
When connecting to the MySQL database on server A from server B, replace "localhost" in the MySQL connect command with 123.123.123.123.
In Cpanel on server A, add the IP address 231.231.231.231 (server B) to the "Access hosts" section on the MySQL page.
========================================================
This is my script to connect:
========================================================
$conec = mysql_connect('123.123.123.123',"login","passwd") or print (mysql_error());
if($conec){
echo "SUCESS";
}else{
echo "FAIL";
}
mysql_select_db('data_base',$conec) or print(mysql_error());
=========================================================
I get conect to mysql with SUCESS, but when I will select the database him mistake comes back.
Access denied for user 'user'@'231.231.231.231' to database 'painel_novadm'
Which is the problem?
i do it below:
======================================================
When connecting to a MySQL database on a given server from a different server, replace "localhost" with the IP address of the machine running the MySQL database.
In the MySQL section in Cpanel, you'd need to add the IP of the machine from which you want to access the database in the "Access hosts" section.
To give an example:
Server A with IP address 123.123.123.123 is running a MySQL database
Server B with IP address 231.231.231.231 wants to access the MySQL database on server A.
When connecting to the MySQL database on server A from server B, replace "localhost" in the MySQL connect command with 123.123.123.123.
In Cpanel on server A, add the IP address 231.231.231.231 (server B) to the "Access hosts" section on the MySQL page.
========================================================
This is my script to connect:
========================================================
$conec = mysql_connect('123.123.123.123',"login","passwd") or print (mysql_error());
if($conec){
echo "SUCESS";
}else{
echo "FAIL";
}
mysql_select_db('data_base',$conec) or print(mysql_error());
=========================================================
I get conect to mysql with SUCESS, but when I will select the database him mistake comes back.
Access denied for user 'user'@'231.231.231.231' to database 'painel_novadm'
Which is the problem?