代码:无法使用提供的设置连接到数据库服务器

编程入门 行业动态 更新时间:2024-10-28 11:28:38
本文介绍了代码:无法使用提供的设置连接到数据库服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

推荐答案

转到您的 myf 并注释该行

bind 127.0.0.1

那么你应该看看你的MySQL用户有足够的权限从其他ips访问。

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

MySQL远程访问

更多推荐

代码:无法使用提供的设置连接到数据库服务器

本文发布于:2023-10-29 03:14:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538552.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   代码   服务器   数据库

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!