Codeigniter: Unable to connect to your database server using the provided settings

末鹿安然 提交于 2019-12-23 13:05:26

问题


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';

A Database Error Occurred:

Unable to connect to your database server using the provided settings.
Filename: third_party/fuel/Loader.php
Line Number: 134

and i can ssh 192.168.1.222, Meanwhile in 192.168.1.222, it's also ok when hostname is localhost.

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.


回答1:


As default a MySQL Server is configured that he allowes only a binding from localhost.

Go to your my.cnf and comment the line

bind 127.0.0.1

Then you should look that your MySQL user has enough rights to access from other ips.

MySQL Remote Access



来源:https://stackoverflow.com/questions/12795300/codeigniter-unable-to-connect-to-your-database-server-using-the-provided-settin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!