代码:无法使用提供的设置连接到数据库服务器 [英] Codeigniter: Unable to connect to your database server using the provided settings

查看:1625
本文介绍了代码:无法使用提供的设置连接到数据库服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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.

MySQL远程访问

这篇关于代码:无法使用提供的设置连接到数据库服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆