修复phpMyAdmin用户“root”@“localhost”拒绝访问

我在PC上使用WAMP Server 2.2。 在phpMyAdmin(版本5.5.24)中,我编辑了'root'用户(用'localhost'host),并给它一个“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错误完全); 我试图删除并重新创buildroot / localhost用户。 似乎没有任何工作。 root / localhost用户似乎没有密码和所有权限,但错误依然存在。

任何想法或如何让这个用户的访问恢复正常,而无需重新安装WAMP?

findC:\wamp\apps\phpmyadmin3.5.1下的config.inc文件在这个文件里find这一行

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

并用其replace

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

我改变了数据库中的密码后,我有同样的问题..我做了什么是更新密码的编辑我以前已经改变,我没有更新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'] = ''; 

当我在phpMyAdmin页面中更改我的“root”密码后,遇到了同样的问题,并且从互联网上寻找解决scheme,但是却无法得到我需要的答案,所以我检查了phpMyAdmin目录中的文档。

转到并编辑该文件

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

寻找线路

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

并将“configuration”更改为“http” ,这将允许您使用浏览器访问phpMyAdmin页面时input用户名和密码。

要么

请参阅相同的phpMyAdmin目录下的文档文件( phpmyadmin414x140123114237\doc\html )以获取帮助并search$cfg['Servers'][$i]['auth_type'] ,您将看到4个选项可以selectlogin到您的phpMyAdmin页面。

好吧..这对我来说似乎很奇怪,但它突然工作!

我所做的是:

  1. 导航到phpMyAdmin文件夹,并编辑文件“config.inc.php”
  2. 看看这行:$ cfg ['Servers'] [$ i] ['password'] ='';
  3. 在“'之间添加了任何密码,比如说'1234'
  4. 重装上本地/ phpmyadmin&127.0.0.1/phpmyadmin(都显示相同的错误)
  5. 恢复“config.inc.php”到旧状态(删除密码)
  6. 重新做了第4步

突然它工作了!

如果你已经有了MySQL的密码,那就写下面提到的:

C:\ wamp \ apps \ phpmyadmin3.5.1下findconfig(dot)inc文件在这个文件里find这一行

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

并用其replace

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

@Dagon有正确的想法,但在细节方面略有欠缺。

如果您使用访问权限127.0.0.1/phpmyadmin并仔细查看在Mysql中设置的用户,您应该看到3个版本的root用户名。

这是因为在MySQL中,每个用户标识都与一个主机相关联,即用户被允许login的PC(IP地址)。 所以你的3个“root”用户标识实际上是同一个用户标识,它可以从3个独立的HOSTSlogin。 通常情况下,“root”具有3个HOSTS设置,127.0.0.1,localhost和:: 1

这些是 :-

localhost是从你的HOSTS文件(c:\ windows \ system32 \ drivers \ etc \ hosts)创build的这台机器的别名。

127.0.0.1是本机的IPv4环回IP地址

:: 1是这台机器的IPv6环回IP地址

您可能发生的情况是,您为root@127.0.0.1设置了密码,但没有设置其他密码。 现在,您的浏览器将'arbtrarily'决定使用:: 1或127.0.0.1作为主机IP,所以当它使用:: 1时,您的login将失败。

所以使用127.0.0.1/phpmyadminlogin,并更改所有3'根'用户名有相同的密码,你不应该再看到这个问题。

还要确保你的HOSTS文件有这2个条目

 127.0.0.1 localhost ::1 localhost 

解决上述错误:

 a) Open Mysql console from the tray of WAMP server b) It will ask for 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服务器

 For this Open config.inc file from the below path C:\wamp\apps\phpmyadmin4.1.14 

并replace这一行

 $cfg['Servers'][$i]['password'] =' '; to `$cfg['Servers'][$i]['password'] = 'admin';` 

我希望这会工作..

使用$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 

什么对我有效:

转到config.inc.php

更改$ cfg ['Servers'] [$ i] ['AllowNoPassword'] = true; 到$ cfg ['Servers'] [$ i] ['AllowNoPassword'] = false;

更改$ cfg ['Servers'] [$ i] ['password'] ='';

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

更改

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

$ cfg ['Servers'] [$ i] ['auth_type'] ='http';

重新加载页面http:// localhost / phpmyadmin

types:根传递:(空)

现在你可以访问它。 🙂

findC:\ xampp \ phpMyAdmin下的config.inc.php文件,并在任何编辑器中打开它。 find以下行:

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

在引号内input所选的密码。 此外,为了使本地/ phpmyadmin要求用户名和密码,find以下行:

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

将上面的行更改为:

 $cfg['Servers'][$i]['auth_type'] = 'cookie'; 

XAMPP \ phpMyAdmin的/ config.inc

找-

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

并将“config”更改为“http”,当您使用浏览器访问phpMyAdmin页面时,可以input用户名和密码。

另外要注意,“设置”(即localhost / phpmyadmin / setup)在处理“无密码”选项时会有错误。 虽然它创build了一个说:

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

参数的实际名称应如下所示:

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

截至今天,2015年10月20日这个“设置”错误存在。

尝试find$ cfg ['Servers'] [$ i] ['password'] =''; 在configuration文件位于wamp / scripts / config.inc.php

然后将密码设置为您的mysql密码并刷新PhpmyAdmin

我也面临这个问题,

我发现密码字段在phpmyadmin的configuration文件中是空白的。 我把这个密码填入数据库设置。 现在它工作正常

我使用这个URL来inputphpMyAdmin http:// localhost:2145 / phpmyadmin,但得到以下错误:
“phpMyAdmin试图连接到MySQL服务器,服务器拒绝连接,你应该检查你的configuration中的主机,用户名和密码,并确保它们对应于MySQL服务器pipe理员给出的信息”
我的config.inc.php文件是

 $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = ''; $cfg['Servers'][$i]['host'] = 'localhost:2145'; $cfg['Servers'][$i]['connect_type'] = 'cookie'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = true; /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlport'] = ''; $cfg['Servers'][$i]['controluser'] = ''; $cfg['Servers'][$i]['controlpass'] = ''; 

这个改变为我解决了这个错误

 $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 

并解决问题