【问题标题】:Database connection error (2): Could not connect to MySQL for Yoomla on local machine [closed]数据库连接错误(2):无法在本地机器上连接 MySQL for Yoomla [关闭]
【发布时间】:2012-12-09 20:52:23
【问题描述】:

今天我有一个在 Joomla 中的新项目。 我在我的电脑上下载了网站代码。 网站管理面板是 cpanel。

我以前从未对 Joomla 网站做过任何事情。

当我在本地机器 (http://localhost/ppp/public_html/index.php) 上打开网站时,它显示数据库连接错误 (2):无法连接到 MySQL。 但是,我已经更改了 configuration.php 文件(我猜我需要更改它):

//Before my changes it was the following:
public $host = 'localhost';
public $user = 'reiuser_reiuser';
public $password = 'password';
public $db = 'reiuser_reiuser';

//After my changes:
public $host = '174.121.134.94'; //IP was displayed in cpanel
public $user = 'reiuser_reiuser';
public $password = 'password';
public $db = 'reiuser_reiuser';

我已阅读有关此错误的信息,并且大多数人说要检查连接数据。 但是,我可以使用这些连接数据成功连接 HeidiSql(用户/密码/数据库已更改)。

也许这里没有足够的信息,但也许 Joomla 开发人员可以建议做什么? 哪个 Joomla 文件正在连接?也许我可以做一些回声来了解错误的原因? 网站正在使用 CPanel。

谢谢。

【问题讨论】:

    标签: mysql joomla cpanel


    【解决方案1】:

    你可以试试 mysql_connect();就在你的 conf 在异常上加上 die() 以确保这是使用的配置而不是其他配置文件

    【讨论】:

    • 有时候遇到一些奇怪的问题,会忘记最简单的事情……
    【解决方案2】:

    当我尝试直接使用 mysql_connect 时,我得到了类似的东西 mysql_connect() [function.mysql-connect]:数据提前结束(mysqlnd_wireprotocol... 我找到的解决方案链接here。

    "出现上述问题是因为PHP和MySql版本不兼容,多半是远程访问db时出现。"

    我降级了我的 php 和 apache(我正在使用 wamp),现在连接正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-21
      • 2018-10-13
      • 2021-03-20
      • 1970-01-01
      • 2016-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多