代码:无法使用提供的设置连接到数据库服务器
我使用codeigniter作为cms框架,如果数据库主机名是localhost,它工作正常。
I use codeigniter as cms framework, if database hostname is localhost, it works correctly.
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'test';
$db['default']['database'] = 'jinma';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
使用上述配置可以正常工作,但如果主机名更改为:
Using above configuration works correctly, but if hostname is changed to:
$db['default']['hostname'] = '192.168.1.222';
发生数据库错误:
Unable to connect to your database server using the provided settings.
Filename: third_party/fuel/Loader.php
Line Number: 134
和我可以ssh 192.168.1.222,
同时在192.168.1.222,当hostname是localhost也是确定。
and i can ssh 192.168.1.222, Meanwhile in 192.168.1.222, it's also ok when hostname is localhost.
我在google搜索并得到一个解决方案add:
I searched in google and got a solution to add:
$db['default']['port'] = '3306';
但不适用于我,任何想法?
but it doesn't work for me, any idea?
谢谢,这是我的第一个问题,对不起是愚蠢的。
Thank you, this is my first question, sorry to be stupid.
转到您的 my.cnf 并注释该行
bind 127.0.0.1
然后你应该看看你的MySQL用户有足够的权限从其他ips访问。
Then you should look that your MySQL user has enough rights to access from other ips.