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)";
“消息:mysqli :: real_connect()[mysqli.real-connect] :( HY000 / 2005):未知的MySQL服务器主机'xxx.xxx.xxx.xxx:3306'(0)”;
this is how my database.php
is configured
这就是我的database.php的配置方式
'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
如果有人能为我提供解决方案,我会表示赞赏
2 个解决方案
#1
1
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,
请允许您的IP访问该数据库。也许这就是你无法连接远程数据库的原因,
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.
- 在您的CPanel中,转到远程数据库访问主机,然后将主机设置为%..这意味着所有IP都可以访问该数据库。
#2
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 )
老兄,你是远程访问数据库,所以转到新服务器的远程MySQL选项,并在添加访问主机文本框中添加写“%”(不带引号),[允许主机通配符输入]并单击添加主机按钮然后通常访问您的数据库配置(无需更改您的代码)
#1
1
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,
请允许您的IP访问该数据库。也许这就是你无法连接远程数据库的原因,
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.
- 在您的CPanel中,转到远程数据库访问主机,然后将主机设置为%..这意味着所有IP都可以访问该数据库。
#2
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 )
老兄,你是远程访问数据库,所以转到新服务器的远程MySQL选项,并在添加访问主机文本框中添加写“%”(不带引号),[允许主机通配符输入]并单击添加主机按钮然后通常访问您的数据库配置(无需更改您的代码)