Reputation: 5111
I have two hosting (1: IP 192.186.234.192 and 2: IP 74.116.84.169), and I have Joomla website files on hosting 1, Joomla mysql database on hosting 2, both hosting 1 and 2 have Cpanel administration. I want run Joomla website on host1 by linked it remotely to mysql database on host 2
Steps that I made:
In Joomla configuration.php file I have changed database section like:
var $host = '74.116.84.169';
var $user = 'artjour';
var $password = 'abc@123';
var $db = 'apuser';
I also have changed the host name by server name like:
var $host = 'servername.mydomainname.com';
But unfortunately:(, Could not connect to MySQL, please it's very important for me to know what's my wrong here.
Thanks in advance.
Upvotes: 0
Views: 2943
Reputation: 17
in the hope that this may help someone I resolved the same situation.
I could access from server A and from command line mysql but I also could not connect my remote joomla database, the httpd server side needed selinux setsebool httpd_can_network_connect_db=1 to enable apache to connect to the remote database.
Upvotes: 1
Reputation: 346
Use a small PHP script like this to see the error other then "Could not connect to MySQL":
<?php
$db_host = "123.456.789";
$db_name = "database";
$db_user = "user";
$db_pass = "password";
$db_table_prefix = "prefix_";
GLOBAL $errors;
GLOBAL $successes;
$errors = array();
$successes = array();
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
GLOBAL $mysqli;
if(mysqli_connect_errno()) {
echo "Conn Error = " . mysqli_connect_error();
exit();
}
?>
Upvotes: 1
Reputation: 1404
You probably have to allow remote SQL connection on server2 with Cpanel : http://www.liquidweb.com/kb/enable-remote-mysql-connections-in-cpanel/
Upvotes: 0