简体   繁体   English

Wordpress错误:(HY000 / 1045):用户'root'@'localhost'的访问被拒绝(使用密码:是)1538行上的wp-db.php

[英]Wordpress error: (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) wp-db.php on line 1538

I get this error message when I try to access wp-admin of my wordpress site: 当我尝试访问我的wordpress网站的wp-admin时,出现以下错误消息:

错误信息

I have set up a local server with Wampserver and it worked fine in the beginning, but now this error message appears whenever i try to go to: localhost/wordpress/wp-admin. 我已经使用Wampserver设置了本地服务器,并且在一开始就可以正常工作,但是现在每当我尝试转到以下位置时,就会出现此错误消息:localhost / wordpress / wp-admin。

I have tried to change the password and it didn't help. 我试图更改密码,但没有帮助。 I have also looked up line 1538 in wp-db.php as the error message suggests but I can't see the problem. 我还在错误消息提示的情况下在wp-db.php中查找了1538行,但看不到问题。 It looks like this: 看起来像这样:

if ( WP_DEBUG ) {
    mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
} else {
    @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
}

Hope someone can help me! 希望可以有人帮帮我!

This error has nothing to do with line 1538 in wp-db.php. 此错误与wp-db.php中的1538行无关。 This line of code is just trying to establish a connection using the credentials that you supplied. 此行代码仅尝试使用您提供的凭据建立连接。 The error is likely with the password provided in your wp-config.php file. 该错误很可能与您的wp-config.php文件中提供的密码有关。

Try to log on to your MySQL server directly using the credentials that you have supplied in the wp-config.php file and see that they work correctly. 尝试使用wp-config.php文件中提供的凭据直接登录到MySQL服务器,并查看它们是否正常运行。

You should be able to connect to to your MySQL instance locally with your "MySQL Command Line Client" in Windows in order to test your password. 您应该能够使用Windows中的“ MySQL命令行客户端”在本地连接到MySQL实例,以便测试密码。

This worked for me: edit wp.config.php, replacing 这对我有用:编辑wp.config.php,替换

define ('DB_HOST', 'localhost');

with

define ('DB_HOST', '127.0.0.1');

I solved this by letting wordpress handle the issue. 我通过让wordpress处理该问题来解决了这一问题。 Just do nothing on wp-config-sample and continue wordpress installation. 只需对wp-config-sample不执行任何操作,然后继续执行wordpress安装即可。 Then wordpress will automatically create wp-config asking db name, user and password. 然后,WordPress将自动创建wp-config,询问数据库名称,用户名和密码。

Open the wp-config.php file and see how MySQL user and passwords are set. 打开wp-config.php文件,查看如何设置MySQL用户和密码。

/** MySQL database username */
define('DB_USER', 'bn_wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'xxxxxx');

For mysql-server-5.7 (I believe older versions didn't have this problem) From my experience so far, and to start from scratch: 对于mysql-server-5.7(我相信较早的版本没有这个问题)到目前为止,根据我的经验,从头开始:

Let's start off with a clean slate: 让我们从一开始就开始:

cd /var/www/html/
wget https://wordpress.org/latest.tar.gz 
tar -xvzf latest.tar.gz
sudo chown -R www-data:www-data /var/www/html/wordpress

This will download, extract, and fix any file permission / ownership issues. 这将下载,提取并修复任何文件许可/所有权问题。

Now we have to fix mysql_native_password issues 现在我们必须修复mysql_native_password问题

SELECT user,authentication_string,plugin,host FROM mysql.user;

you will see a table as such: 您将看到这样的表格:

+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+

then run: 然后运行:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Where 'password' is your root password that you set. 其中“密码”是您设置的根密码。

After doing this, run: 完成此操作后,运行:

FLUSH PRIVILEGES;
SELECT user,authentication_string,plugin,host FROM mysql.user;

You should see your root password inside. 您应该在其中看到您的root密码。

This will fix the issue. 这样可以解决问题。

Also, you will run into the same exact issue with phpMyAdmin, so the same concepts with "mysql_native_password" and ALTERING your user, and file/folder ownership as we did above will fix these issues. 另外,您将遇到与phpMyAdmin完全相同的问题,因此,与上述相同的使用“ mysql_native_password”和更改用户以及文件/文件夹所有权的概念将解决这些问题。

Hope this helped. 希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE [HY000] [1045]拒绝用户'root'@'localhost'的访问(使用密码:是)错误 - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) error occurs 警告:mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp64\www\web\db.php 在第 3 行 - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp64\www\web\db.php on line 3 PHP Owncloud [1045] SQLSTATE [HY000] [1045]用户'ownclouduser'@'localhost'的访问被拒绝(使用密码:是) - PHP Owncloud [1045] SQLSTATE[HY000] [1045] Access denied for user 'ownclouduser'@'localhost' (using password: YES) SQLSTATE[HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:YES)? - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)? (HY000/1045):使用 Windows 拒绝用户 'root'@'localhost'(使用密码:YES)的访问 - (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) using Windows SQLSTATE [HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:YES)symfony2 - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2 无法迁移 SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:YES) - Cannot migrate SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) Symfony-理论:用户'root'@'localhost'的SQLSTATE [HY000] [1045]访问被拒绝(使用密码:是) - Symfony - doctrine: SQLSTATE[HY000] [1045] access denied for user 'root'@'localhost' (using password: YES) (HY000/1045) 用户 'root'@'localhost' 访问被拒绝(使用密码:是) - (HY000/1045) Access denied for user 'root'@'localhost'(using password: YES) Illuminate\Database\QueryException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (使用密码: YES) - Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM