首页 > 解决方案 > 在终端中重置密码时如何修复用户'root'@'localhost'的访问被拒绝不起作用

问题描述

我对设置 WebServer 不熟悉,所以我看了这篇关于如何使用 PHPMyAdmin 和 MySQL 的教程。

我使用 macOS High Sierra。

这是我到目前为止所做的:

我想知道配置文件是否包含一些阻止我成功的错误。config.inc.php 文件存储在Macintosh HD > Library > WebServer > Documents > phpMyAdmin > config下。当我从 config 文件夹中删除此文件并将其放在常规 phpMyAdmin 文件夹下时,我收到了相同的错误消息。

config.inc.php 中的服务器配置可能是问题所在。

    /* Servers configuration */
    $i = 0;

    /* Server: localhost -> 127.0.0.1 [1] */
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'localhost';
    $cfg['Servers'][$i]['host'] = 'localhost'; /* was previously = 'localhost'; */
    $cfg['Servers'][$i]['port'] = '';
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'password';

我希望使用用户名登录:root 和密码:密码没有任何问题。

相反,我收到错误mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

几周前我在 StackOverflow 上查找了这个问题,但似乎解决这个问题的人正在使用 XAMPP。安装 XAMPP 可能会使事情变得更糟,因为我已经安装了 config.inc.php,并且默认设置与来自 XAMPP 的设置不同。

我遵循了有关如何刷新权限和更改密码以访问 MySQL 的教程,但我的终端无法识别这些命令。我收到不存在这样的命令的错误。

标签: phpmysqlphpmyadmin

解决方案


推荐阅读