database 数据库连接错误 (3): 无法连接到数据库',

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13299175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:46:11  来源:igfitidea点击:

Database connection error (3): Could not connect to database',

databasejoomlaxampp

提问by user1801410

I upgrade my xampp to 1.8 from 1.7 by uninstalling 1.7 but did not uninstall the htdocs and mysql data folder. But my problem now is that my site are not displaying, my joomla 2.5 sites give: Database connection error (3): Could not connect to database, while joomla 1.5 sites give errors such as:

我通过卸载 1.7 将我的 xampp 从 1.7 升级到 1.8,但没有卸载 htdocs 和 mysql 数据文件夹。但我现在的问题是我的站点没有显示,我的 joomla 2.5 站点给出:数据库连接错误 (3):无法连接到数据库,而 joomla 1.5 站点给出了如下错误:

Strict Standards: Non-static method JLoader::import() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\import.php on line 29

Strict Standards: Non-static method JLoader::register() should not be called statically in C:\xampp\htdocs\osu\libraries\loader.php on line 71

Strict Standards: Non-static method JLoader::import() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\import.php on line 32

Strict Standards: Non-static method JLoader::register() should not be called statically in C:\xampp\htdocs\osu\libraries\loader.php on line 71

Strict Standards: Non-static method JLoader::load() should not be called statically in C:\xampp\htdocs\osu\libraries\loader.php on line 161

Strict Standards: Non-static method JLoader::register() should not be called statically in C:\xampp\htdocs\osu\libraries\loader.php on line 138

Strict Standards: Non-static method JRequest::clean() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\import.php on line 33

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 463

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 464

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 465

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 466

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 467

Strict Standards: Non-static method JRequest::_cleanArray() should not be called statically in C:\xampp\htdocs\osu\libraries\joomla\environment\request.php on line 468

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\osu\libraries\joomla\import.php:46) in C:\xampp\htdocs\osu\libraries\joomla\factory.php on line 566 Database Error: Unable to connect to the database:Could not connect to database

严格标准:非静态方法 JLoader::import() 不应在 C:\xampp\htdocs\osu\libraries\joomla\import.php 第 29 行静态调用

严格标准:非静态方法 JLoader::register() 不应在 C:\xampp\htdocs\osu\libraries\loader.php 第 71 行静态调用

严格标准:非静态方法 JLoader::import() 不应在 C:\xampp\htdocs\osu\libraries\joomla\import.php 第 32 行静态调用

严格标准:非静态方法 JLoader::register() 不应在 C:\xampp\htdocs\osu\libraries\loader.php 第 71 行静态调用

严格标准:非静态方法 JLoader::load() 不应在 C:\xampp\htdocs\osu\libraries\loader.php 第 161 行静态调用

严格标准:非静态方法 JLoader::register() 不应在 C:\xampp\htdocs\osu\libraries\loader.php 中的第 138 行静态调用

严格标准:非静态方法 JRequest::clean() 不应在 C:\xampp\htdocs\osu\libraries\joomla\import.php 中的第 33 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 463 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 464 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 465 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 466 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 467 行静态调用

严格标准:非静态方法 JRequest::_cleanArray() 不应在 C:\xampp\htdocs\osu\libraries\joomla\environment\request.php 中的第 468 行静态调用

警告:无法修改标题信息 - 标题已由 C:\xampp\htdocs\osu\libraries\joomla\factory 中的(输出开始于 C:\xampp\htdocs\osu\libraries\joomla\import.php:46)发送。 php on line 566 Database Error: Unable to connect to the database:Could not connect to database

Please what was my error. Is there a special way to have backed up database. I am now running xampp 1.8.1 on windows 7. Upgraded from xampp 1.7.0

请问我的错误是什么。有没有一种特殊的方式来备份数据库。我现在在 Windows 7 上运行 xampp 1.8.1。从 xampp 1.7.0 升级

回答by Kostis

How to fix strict standards error: http://vuthakh.blogspot.gr/2012/07/how-to-fix-joomla-error-strict.html

如何修复严格的标准错误:http: //vuthakh.blogspot.gr/2012/07/how-to-fix-joomla-error-strict.html

For the "Unable to connect to database error" check your configuration file to see if db name, password etc are correct

对于“无法连接到数据库错误”,请检查您的配置文件以查看数据库名称、密码等是否正确

回答by Techie

This error can be fix by entering the correct values in the configuration.php which contains in your Joomla root directory.

可以通过在包含在 Joomla 根目录中的 configuration.php 中输入正确的值来修复此错误。

File looks like this below.

文件如下所示。

Config

配置

Database connection error (3): Could not connect to database

数据库连接错误(3):无法连接到数据库

Problem:This error message usually means that you are connecting to the wrong database server. For most Joomla installations, the joomla files themselves and the database it connects to are on the same server. When this is the case, "localhost" should be used the database server. We recreated this error message by setting the database host to "localhosttt" (localhost spelled wrong).

问题:此错误消息通常表示您连接到错误的数据库服务器。对于大多数 Joomla 安装,joomla 文件本身和它连接的数据库在同一台服务器上。在这种情况下,应使用“localhost”作为数据库服务器。我们通过将数据库主机设置为“localhosttt”(localhost 拼写错误)重新创建了此错误消息。

Solution:If your Joomla site is setup like most, check your configuration.php file and ensure your database host is set to "localhost". This is setting looks like the following in your config file:

解决方案:如果您的 Joomla 站点设置与大多数类似,请检查您的 configuration.php 文件并确保您的数据库主机设置为“localhost”。此设置在您的配置文件中如下所示:

public $host = 'localhost';

公共 $host = '本地主机';

Database connection error (2): Could not connect to MySQL.

数据库连接错误 (2):无法连接到 MySQL。

Problem:This error message generally means that your Joomla's configuration.php file has either the wrong database name or database username. In our testing environment, we changed both the database username and password, and in each separate occasion the same error message occurred.

问题:此错误消息通常表示您的 Joomla 的 configuration.php 文件具有错误的数据库名称或数据库用户名。在我们的测试环境中,我们更改了数据库用户名和密码,并且在每个单独的情况下都出现了相同的错误消息。

Solution:You should review your configuration.php file and ensure you are using the correct MySQL username and password. These settings will appear in the file as:

解决方案:您应该检查您的 configuration.php 文件并确保您使用正确的 MySQL 用户名和密码。这些设置将在文件中显示为:

public $user = 'userna5_dbuser'; public $password = 'dbpass';

公共 $user = 'userna5_dbuser'; 公共 $password = 'dbpass';

If you are sure the settings are correct, it is recommend to reset your database user's password and update your configuration.php file with the new password. This will help ensure that you have the correct database password set.

如果您确定设置正确,建议重置您的数据库用户密码并使用新密码更新您的 configuration.php 文件。这将有助于确保您设置了正确的数据库密码。

Only if you still get Strict Standards: Non-static method JLoader::import(), to fix Strict Standards: Non-static method JLoader::import(),

只有当你仍然得到严格标准:非静态方法 JLoader::import() 时,才能修复严格标准:非静态方法 JLoader::import()

change the following line in the php.ini file:

更改 php.ini 文件中的以下行:

Line 516: error_reporting = E_ALL | E_STRICT

TO

Line 516: error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Save that and restart Apache and you should be good to go with installing and working with Joomla! on XAMPP

保存并重新启动 Apache,您应该很高兴安装和使用 Joomla!在 XAMPP 上

回答by humHann

Joomla gave me Database connection error (3): Could not connect to databaseerror when I accidently forgot to turn off PHP safe mode. Hopefully saves someone trouble.

Joomla 给了我数据库连接错误 (3):当我不小心忘记关闭 PHP 安全模式时无法连接到数据库错误。希望可以省去麻烦。

回答by user2118400

The error Database connection error (3): Could not connect to database can also occur if the database user does not have permissions granted for the database. If you are using cPanel:

如果数据库用户没有为数据库授予权限,也会发生错误数据库连接错误 (3):无法连接到数据库。如果您使用的是 cPanel:

  1. Select MySQL Databases.
  2. Scroll down to Add User To Database at the bottom on the page.
  3. Select the user for which you wish to check permissions.
  4. Select the database for which you wish to check the users permissions.
  5. Make sure at least the following permissions are checked:

    • INSERT
    • SELECT
    • UPDATE
    • DELETE

      For installing components the following permissions will also be needed:

    • CREATE
    • ALTER
    • DROP
  6. Click the Make Changes button
  1. 选择 MySQL 数据库。
  2. 向下滚动到页面底部的将用户添加到数据库。
  3. 选择您要检查其权限的用户。
  4. 选择要检查用户权限的数据库。
  5. 确保至少检查了以下权限:

    • 插入
    • 选择
    • 更新
    • 删除

      要安装组件,还需要以下权限:

    • 创建
    • 改变
    • 降低
  6. 单击“进行更改”按钮