修复拒绝用户访问的问题';根'@';本地主机';对于phpMyAdmin

修复拒绝用户访问的问题';根'@';本地主机';对于phpMyAdmin,php,mysql,phpmyadmin,wamp,Php,Mysql,Phpmyadmin,Wamp,我在PC上使用WAMP Server 2.2。在phpMyAdmin(版本5.5.24)中,我编辑了“root”用户(使用“localhost”主机),并给它一个“root”密码。这被证明是一个很大的错误,我正试图纠正这个错误。现在,当我转到localhost/phpmyadmin/时,我会看到左侧的数据库菜单,但主框架有一个错误,显示: #1045 - Access denied for user 'root'@'localhost' (using password: NO) phpMyAdm

我在PC上使用WAMP Server 2.2。在phpMyAdmin(版本5.5.24)中,我编辑了“root”用户(使用“localhost”主机),并给它一个“root”密码。这被证明是一个很大的错误,我正试图纠正这个错误。现在,当我转到localhost/phpmyadmin/时,我会看到左侧的数据库菜单,但主框架有一个错误,显示:

#1045 - Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the 
connection. You should check the host, username and password in your 
configuration and make sure that they correspond to the information given 
by the administrator of the MySQL server.
如果我转到127.0.0.1/phpmyadmin,我不会得到错误,一切正常

我尝试将用户的密码改回无密码;我试图修改config.inc.php文件以添加新密码(但这使phpMyAdmin错误完全消失);我尝试删除并重新创建root/localhost用户。似乎什么都不管用。root/localhost用户似乎没有密码和所有权限,但错误仍然存在


我有什么想法,或者如何让该用户在不重新安装WAMP的情况下恢复正常访问?

@Dagon的想法是正确的,但在细节上有点欠缺

如果您使用access
127.0.0.1/phpmyadmin
并仔细查看在MysQL中设置的用户,您应该会看到3个版本的
root
用户名

这是因为在MySQL中,每个用户ID都与主机关联,即允许用户登录的PC(ip地址)。因此,您的3个“root”用户ID实际上是允许从3个不同主机登录的同一个用户ID。通常开箱即用的“root”有3个主机设置,127.0.0.1、localhost和::1

这些是:

localhost是根据主机文件(c:\windows\system32\drivers\etc\HOSTS)创建的此计算机的别名

127.0.0.1是此计算机的IPv4环回ip地址

::1是此计算机的IPv6环回ip地址

可能发生在您身上的是,您已经为设置了密码root@127.0.0.1但其他人都没有。 现在,您的浏览器将“任意”决定使用::1或127.0.0.1作为主机ip,因此当它使用::1时,您的登录将失败

因此,请使用
127.0.0.1/phpmyadmin
登录,并将所有3个“root”用户名更改为具有相同的密码,您将不会再看到此问题

还要确保主机文件包含这两个条目

127.0.0.1  localhost
::1        localhost

在phpMyAdmin页面中更改我的“root”的密码后,我遇到了同样的问题,也在从internet上寻找解决方案,但没有得到我需要的答案,因此我检查了phpMyAdmin目录中的文档

转到并编辑该文件

\modules\phpmyadmin414x140123114237\config.sample.inc.php
找线

$cfg['Servers'][$i]['auth_type'] = 'config'
并将'config'更改为'http',这将允许您在使用浏览器进入phpMyAdmin页面时键入用户名和密码


请参阅同一phpMyAdmin目录下的文档文件(
phpmyadmin414x140123114237\doc\html
)以获取帮助并搜索
$cfg['Servers'][$i]['auth_type']
您将看到4个选项可供选择,包括如何登录到您的phpMyAdmin页面。

C:\wamp\apps\phpmyadmin3.5.1下查找
config.inc
文件 在这个文件中找到 这一行

$cfg['Servers'][$i]['password'] =";
并将其替换为

$cfg['Servers'][$i]['password'] = 'Type your root password here';

嗯。。这对我来说似乎很奇怪,但它突然奏效了

我所做的就是:

  • 导航到phpMyAdmin文件夹,并编辑文件“config.inc.php”
  • 查找行:$cfg['Servers'][$i]['password']=''
  • 添加了“”之间的任何密码,例如“1234”
  • 重新加载的localhost/phpmyadmin&127.0.0.1/phpmyadmin(两者显示相同的错误)
  • 将“config.inc.php”恢复为旧状态(删除密码)
  • 重新执行步骤4

  • 突然,它成功了

    在更改数据库中的密码后,我遇到了同样的问题。。我所做的是 我之前更改的更新密码的编辑,我没有在config.inc.php和相同的用户名中更新 在D:\xamp\phpMyAdmin\config.inc下

    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = **'root'**;
    $cfg['Servers'][$i]['password'] = **'epufhy**';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    $cfg['Lang'] = '';
    

    要解决上述错误,请执行以下操作:-

    a)  Open Mysql console from the tray of WAMP server
    
    b)  It will ask for a password(you might have set this password earlier when u installed MySql in your system)(In my case it is admin)
    
    c)  Enter admin (press enter)
    
    现在,这意味着您的PhpMyAdmin假定您的MySql没有密码,并且无法连接MySql,但您可以通过提供密码来连接MySql服务器 对于此打开的config.inc文件,请从下面的路径

    C:\wamp\apps\phpmyadmin4.1.14

    然后换掉这条线

    $cfg['Servers'][$i]['password']=''

    $cfg['Servers'][$i]['password']='admin'


    我希望它能工作…

    xampp\phpMyAdmin/config.inc

    发现-

    $cfg['Servers'][$i]['auth_type']='config'


    并将“config”更改为“http”,这将允许您在使用浏览器进入phpMyAdmin页面时键入用户名和密码。

    使用
    $cfg['Servers'][$i]['auth_type']='config'是不安全的

    将cookie与
    $cfg['Servers'][$i]['auth_type']='cookie'一起使用我认为更好

    我还补充说:

    $cfg['LoginCookieRecall'] = true;
    
    $cfg['LoginCookieValidity'] = 100440;
    
    $cfg['LoginCookieStore'] = 0;  //Define how long login cookie should be stored in browser. Default 0 means that it will be kept for existing session. This is recommended for not trusted environments.
    $cfg['LoginCookieDeleteAll'] = true; //If enabled (default), logout deletes cookies for all servers, otherwise only for current one. Setting this to false makes it easy to forget to log out from other server, when you are using more of them.
    
    我在phi.ini中添加了这个

    session.gc_maxlifetime=150000
    

    如果您有mysql的现有密码,请按如下所述编写:

    C:\wamp\apps\phpmyadmin3.5.1下查找config(dot)inc文件在此文件中查找这一行

    $cfg['Servers'][$i]['password']=”;

    并将其替换为

    $cfg['Servers'][$i]['password'] = 'Type your root password here';
    
    $cfg['Servers'][$i]['password']=**'your-password'**;

    还要注意,“setup”(即localhost/phpmyadmin/setup)在处理“no password”选项的方式中有一个错误。同时,它会创建一行,显示:

    $cfg['Servers'][$i]['nopassword'] = true;
    
    参数的实际名称应如下所示:

    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    

    此“设置”错误自2015年10月20日起存在。

    尝试查找$cfg['Servers'][$i]['password']=''; 在位于wamp/scripts/config.inc.php的配置文件中

    然后将密码设置为您的mysql密码并刷新PhpmyAdmin,这对我有用:

    转到config.inc.php

    改变

    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    
    $cfg['Servers'][$i]['password'] = '';
    
    $cfg['Servers'][$i]['auth_type'] = 'config';
    

    改变

    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    
    $cfg['Servers'][$i]['password'] = '';
    
    $cfg['Servers'][$i]['auth_type'] = 'config';
    

    改变

    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    
    $cfg['Servers'][$i]['password'] = '';
    
    $cfg['Servers'][$i]['auth_type'] = 'config';
    

    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    
    sudo service mysql stop
    /opt/lampp/lampp start