MySQL 说:文档 #1045 - 用户 'root'@'localhost' 访问被拒绝(使用密码:NO)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11096045/
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-08-31 13:52:31  来源:igfitidea点击:

MySQL said: Documentation #1045 - Access denied for user 'root'@'localhost' (using password: NO)

mysqlphpmyadminxamppmysql-error-1045

提问by Saya Antisosial

I installed xampp,but when I tried to run it I got an error as thus:

我安装了 xampp,但是当我尝试运行它时,出现如下错误:

Error

错误

MySQL said: Documentation

MySQL 说: 文档

1045 - Access denied for user 'root'@'localhost' (using password: NO)

1045 - 用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)

Connection for controluser as defined in your configuration failed. 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.

配置中定义的 controluser 连接失败。phpMyAdmin 尝试连接 MySQL 服务器,服务器拒绝连接。您应该检查配置中的主机、用户名和密码,并确保它们与 MySQL 服务器管理员提供的信息相对应。

I tried to search on internet for a solution, but I still can't fix my problem. I have already checked whether I used a password or not in config.inc.phpfile but i have not used any password.Also, when i try to access with a password, I still can't solve this problem.

我试图在互联网上搜索解决方案,但我仍然无法解决我的问题。我已经检查过我是否在config.inc.php文件中使用了密码,但我没有使用任何密码。另外,当我尝试使用密码访问时,我仍然无法解决这个问题。

I hope anyone can help me. .thank you

我希望任何人都可以帮助我。。谢谢你

回答by supernewbie

I had this problem after changing the password for the root user in phpMyAdmin. I know nothing about programming but I solved it by doing the following:

phpMyAdmin 中更改 root 用户的密码后,我遇到了这个问题。我对编程一无所知,但我通过执行以下操作解决了它:

  1. Go to file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php(I guess you would replace "wamp" with the name of your server if you're not using Wamp Server)

  2. Find the line $cfg['Servers'][$i]['password']=''and change this to

    $cfg['Servers'][$i]['password']='NO'
    
  3. Try opening phpMyAdminagain, and hopefully the message will now read "Access denied for user 'root'@'localhost'(using password: YES)

  4. Now change the password in the above line to 'yourpassword' (whatever you had set it to before)

  1. 转到文件C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php(如果您不使用 Wamp Server,我想您会将“wamp”替换为您的服务器名称)

  2. 找到该行$cfg['Servers'][$i]['password']=''并将其更改为

    $cfg['Servers'][$i]['password']='NO'
    
  3. 再次尝试打开phpMyAdmin,希望消息现在显示为“用户'root'@'localhost'访问被拒绝(使用密码:YES)

  4. 现在将上面一行中的密码更改为“ yourpassword”(无论您之前设置为什么

Hope this helps somebody.

希望这可以帮助某人。

回答by Sifudu Peter

Go to the file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php

转到文件 C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php

Find the line $cfg['Servers'][$i]['password']='' and change it to

找到行 $cfg['Servers'][$i]['password']='' 并将其更改为

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

where rootis the name of the password you had set in this instance

root您在此实例中设置的密码名称在哪里

Hope this helps somebody.

希望这可以帮助某人。

回答by Joseph Steven Martinez

Step one:Go to... C:\xampp\phpMyAdmin

第一步:转到... C:\xampp\phpMyAdmin

Step Two:Open the config.inc.phpfile

第二步:打开config.inc.php文件

Step Three:Locate the following information and change the password.

第三步:找到以下信息并修改密码。

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'ENTER_YOUR_USER_NAME_HERE';
$cfg['Servers'][$i]['password'] = 'ENTER_YOUR_PASS_HERE';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

回答by Mark Kasson

Here's the solution to getting the 1045 Access denied for user 'root'@'localhost' (using password: NO)in phpMyAdmin.

这是获取1045 Access denied for user 'root'@'localhost' (using password: NO)phpMyAdmin的解决方案。

First here's what happens:

首先是发生了什么:

The problem occurs when you change over from using phpMyAdmin with no password and mysql with no root password. You change root in mysql to having a root password. You dutifully change phpMyAdmin's config.ini.php file's $cfg['Servers'][$i]['password']=''line to include your password and restart everything you can find, but phpMyAdmin still can't get through.

当您从使用没有密码的 phpMyAdmin 和没有 root 密码的 mysql 转换过来时,就会出现问题。您将 mysql 中的 root 更改为具有 root 密码。您尽职尽责地更改 phpMyAdmin 的 config.ini.php 文件的$cfg['Servers'][$i]['password']=''行以包含您的密码并重新启动您能找到的所有内容,但 phpMyAdmin 仍然无法通过。

The reason is that your browser still contains cookies for phpMyAdmin and those cookies reflect not needing a password to access mysql.

原因是您的浏览器仍然包含 phpMyAdmin 的 cookie,这些 cookie 反映不需要密码来访问 mysql。

The solution:

解决方案:

Clear out the cookies relating to phpMyAdmin. Its browser specific, but in my Firefox, its under Tools > Page Info > Cookies.

清除与 phpMyAdmin 相关的 cookie。它特定于浏览器,但在我的 Firefox 中,它位于“工具”>“页面信息”>“Cookie”下。

You might need to relog in with phpMyAdmin or use the signon.php script (under /examples in my WAMP install).

您可能需要使用 phpMyAdmin 重新登录或使用 signon.php 脚本(在我的 WAMP 安装中的 /examples 下)。

回答by Himanshu Bhandari

Try this:

尝试这个:

  1. Open config.inc.phpfile in the phpmyadmindirectory
  2. Find line 21: $cfg['Servers'][$i]['password'] = '';
  3. Change it to: $cfg['Servers'][$i]['password'] = 'your_password';
  4. Restart XAMPP
  1. 打开目录下的config.inc.php文件phpmyadmin
  2. 找到第 21 行: $cfg['Servers'][$i]['password'] = '';
  3. 将其更改为: $cfg['Servers'][$i]['password'] = 'your_password';
  4. 重启XAMPP

Reference

参考

回答by Daniel Magnusson

Try this:

尝试这个:

1. xampp/htdocs/xampp/cds.php

change line 4 to: mysql_connect("localhost","root","enter password here");
change line 64 to: if(!mysql_connect("localhost","root","enter password here"))

From here

从这里

回答by Jaydipsinh

reset your mysql password on xampp security page. restart your mysql service and then access the phpmyadmin page using your password. i tried it. this is working fine for me.

在 xampp 安全页面上重置您的 mysql 密码。重新启动您的 mysql 服务,然后使用您的密码访问 phpmyadmin 页面。我尝试过这个。这对我来说很好用。

回答by Tim Leon

I had this problem with a fresh install of wamp and using only default settings without setting any passwords. I found an incorrect default setting and I solved it by the following steps:

我在全新安装 wamp 并且仅使用默认设置而不设置任何密码时遇到了这个问题。我发现一个不正确的默认设置,我通过以下步骤解决了它:

  1. Go to C:\wamp\apps\phpmyadmin4.1.14 (Your phpmyadmin version# may differ)
  2. open the file config.inc in a text editor
  3. find the line: $cfg['Servers'][$i]['host'] = '127.0.0.1';
  4. change it to $cfg['Servers'][$i]['host'] = 'localhost';
  5. save the file
  6. restart all services in wamp
  1. 转到 C:\wamp\apps\phpmyadmin4.1.14(您的 phpmyadmin 版本#可能不同)
  2. 在文本编辑器中打开文件 config.inc
  3. 找到这一行: $cfg['Servers'][$i]['host'] = '127.0.0.1';
  4. 将其更改为 $cfg['Servers'][$i]['host'] = 'localhost';
  5. 保存文件
  6. 重新启动 wamp 中的所有服务

The problem seems to be that someone forgot to make the server and host match in the configuration files.

问题似乎是有人忘记在配置文件中使服务器和主机匹配。

回答by Lars Dormans

Try resetting your password since it seems it has changed you can reset your password by going to

尝试重置您的密码,因为它似乎已更改您可以通过以下方式重置您的密码

C:\xampp\mysql

and clicking on the resetroot.bat file

并点击 resetroot.bat 文件

Then change in the php config file the password back to blank and you should have access again

然后在php配置文件中将密码改回空白,您应该可以再次访问

回答by y0ung0d

  1. Open the config.inc.phpfile in the WAMPphpmyadmindirectory

  2. Change the line ['Servers'][$i]['password'] = ''to

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

  3. Clear browser cookies

  4. Then Restart all services on WAMP

  1. 打开目录下的config.inc.php文件WAMPphpmyadmin

  2. 将行更改['Servers'][$i]['password'] = ''

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

  3. 清除浏览器 cookie

  4. 然后重新启动所有服务 WAMP

This worked for me.

这对我有用。

NB: the password to use has to be the MySQL password.....

注意:要使用的密码必须是 MySQL 密码.....