3

I have moved my database to a different server and my applications files are still in the current server.

I have tried many ways to connect my database in the new server, But still it says

"Message: mysqli::real_connect() [mysqli.real-connect]: (HY000/2005): Unknown MySQL server host 'xxx.xxx.xxx.xxx:3306' (0)";

this is how my database.php is configured

'hostname' => 'xxx.xxx.xxx.xxx:3306',
'username' => '[my database user]',
'password' => '[my database password]',
'database' => '[my db]',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,

I appriciate if anyone can provide me a solution

4
  • try the hostname without :3306, port is a separate option and it should probably default to 3306. ellislab.com/codeigniter/user-guide/database/configuration.html Commented Oct 25, 2015 at 10:23
  • Hi, I have tried without port also. but still same results Commented Oct 25, 2015 at 10:26
  • Are you able to connect to the database from the web server at all? Ie using the normal mysql client. Commented Oct 25, 2015 at 10:27
  • have you access to WHM? Commented Oct 25, 2015 at 10:53

2 Answers 2

3

Commonly like this...

$db['default']['hostname'] = 'XXX.XX.XX.XXX'; //IP of server 
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'database_name';

Note:

Please allow your IP to be access for that database. Maybe that reasons why you can't connect with your remote database,

Hint:

  • In your CPanel, go to Remote Database Access Hosts and then set the host as % .. its means all IPs can be access to that database.
Sign up to request clarification or add additional context in comments.

1 Comment

I have allowed the IP too. but still I couldn't connect to the database
0

Dude, you are remotely access database, so go to your new server's Remote MySQL option, and add write " % " ( without quotes ) in Add an Access Host textbox, [ to allow Host wildcard entry ] and click to Add Host button and then normally access your database configs ( no need to change your codes )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.