MySQL #1045 - 用户 'root'@'localhost' 访问被拒绝(使用密码:YES)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16845715/
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
#1045 - Access denied for user 'root'@'localhost' (using password: YES)
提问by Prakash
This might seem redundant but I was unable to find a correct solution.
这似乎是多余的,但我无法找到正确的解决方案。
I was unable to login to mysql using the mysql console.It is asking for a password and I have no clue what I actually entered.(Is there a way to get the password or change it?) This is how my config.inc look.
我无法使用 mysql 控制台登录到 mysql。它要求输入密码,我不知道我实际输入了什么。(有没有办法获取密码或更改密码?)这就是我的 config.inc 的样子.
When I try to open phpmyadmin I get this error(#1045 - Access denied for user 'root'@'localhost' (using password: YES))
当我尝试打开 phpmyadmin 时出现此错误(#1045 - Access denied for user 'root'@'localhost'(使用密码:YES))
<?php
/* Servers configuration */
$i = 0;
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'prakash123';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* End of servers configuration */
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
?>
I have tried to uninstall( Plus Deleted all the related files) WAMP and reinstall.It didn't help either. While reinstalling WAMP server it is not asking for any username password stuff I don't know why. Any help is highly appreciated.
我试图卸载(加上删除所有相关文件)WAMP 并重新安装。它也没有帮助。在重新安装 WAMP 服务器时,它不会要求任何用户名密码的东西,我不知道为什么。任何帮助都受到高度赞赏。
采纳答案by Prakash
The problem was I have 2 instances of Mysql installed and I didn't know the password for both instances.Just check if port 80 is used by any of the programs. This is what I did
问题是我安装了 2 个 Mysql 实例,但我不知道这两个实例的密码。只需检查端口 80 是否被任何程序使用。这就是我所做的
1.Quit Skype because it was using port 80.(Please check if port 80 is used by any other program).
1.退出Skype,因为它正在使用端口80。(请检查端口80是否被任何其他程序使用)。
2.Search for Mysql services in task manager and stop it.
2.在任务管理器中搜索Mysql服务并停止。
3.Now delete all the related mysql files.Make sure you delete all the files.
3.现在删除所有相关的mysql文件。确保删除所有文件。
4.Reinstall
4.重新安装
回答by user2314737
I first changed the root password running mysql at a prompt with
我首先在提示符下更改了运行 mysql 的 root 密码
mysql -u root -p
Update password:
更新密码:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
Edited line in the file config.inc.php
with the new root password:
config.inc.php
使用新的 root 密码编辑文件中的行:
$cfg['Servers'][$i]['password'] = 'MyNewPass'
Stop and re-start mysql service (in Windows: mysql_stop.bat
/mysql_start.bat
)
停止并重新启动 mysql 服务(在 Windows 中:mysql_stop.bat
/ mysql_start.bat
)
and got phpMyAdmin to work!
并让 phpMyAdmin 开始工作!
EDIT 2017: for MySQL≥5.7 use authentication_string
in place of Password
(see this answer):
编辑 2017:对于 MySQL≥5.7 使用authentication_string
代替 Password
(请参阅此答案):
UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
回答by yunhasnawa
Well, there are many solutions already given above. If there are none of them works, maybe you should just try to reset your password again to 'root' as described here, and then reopen http://localhost/phpMyAdmin/
in other browser. At least this solution works for me.
嗯,上面已经给出了许多解决方案。如果它们都不起作用,也许您应该尝试按照此处所述再次将密码重置为“root” ,然后http://localhost/phpMyAdmin/
在其他浏览器中重新打开。至少这个解决方案对我有用。
回答by ramin rostami
mysql -u root -p
UPDATE mysql.user SET Password=PASSWORD('mypass') WHERE User='root';
- Flush the privileges:
FLUSH PRIVILEGES;
- Exit by typing:
Exit
Edited line in the file config.inc.php with the new root password:
$cfg['Servers'][$i]['password'] = 'mypass'
be succss
mysql -u root -p
UPDATE mysql.user SET Password=PASSWORD('mypass') WHERE User='root';
- 刷新特权:
FLUSH PRIVILEGES;
- 通过键入退出:
Exit
使用新的 root 密码编辑文件 config.inc.php 中的行:
$cfg['Servers'][$i]['password'] = 'mypass'
成功
回答by halkujabra
Go to 'config.inc.php'. Write your password over here - $cfg['Servers'][$i]['password'] =''
转到“config.inc.php”。在这里写下你的密码——$cfg['Servers'][$i]['password'] =''
回答by Timi Jegede
This worked for me. In your config file
这对我有用。在你的配置文件中
$cfg['Servers']['$i']['password'] = 'yourpassword';
In your mysql shell, login as root
在您的 mysql shell 中,以 root 身份登录
mysql -u root
change your password or update if you've forgotten the old one
如果忘记旧密码,请更改密码或更新
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
stop and restart your mysql server from the xampp control panel. phpmyadmin can login to see your databases
从 xampp 控制面板停止并重新启动您的 mysql 服务器。phpmyadmin 可以登录查看你的数据库
回答by hussainfrotan
Go to config.inc.php
, find $cfg['Servers'][$i]['password']
and remove any password provided, i.e change $cfg['Servers'][$i]['password'] = 'password';
with $cfg['Servers'][$i]['password'] = '';
转到config.inc.php
,查找$cfg['Servers'][$i]['password']
并删除提供的任何密码,即更改$cfg['Servers'][$i]['password'] = 'password';
为$cfg['Servers'][$i]['password'] = '';
Now you can launch phpMyAdmin
现在您可以启动phpMyAdmin
Selecting Usersmenu from phpMyAdmin, select the rootuser and click Edit previlidges. Now scroll down to Change Passwordarea, switch between No Passwordand Passwordto provide your new password. that's it.
从phpMyAdmin 中选择Users菜单,选择root用户并单击Edit previludges。现在向下滚动到更改密码区域,在无密码和密码之间切换以提供您的新密码。就是这样。
回答by Saturminus Combie
This process is quite simple in correcting the the error. What is happening is a failure to connect to phpMyAdmin. In order to fix the problem you simply need to provide the correct password to the system phpMyAdmin configuration file located in apps\phpMyadmin\config.ini.php 1. the root should already be set as user 2. Insert the password between ' ' and that it.
这个过程在纠正错误方面非常简单。发生的情况是无法连接到 phpMyAdmin。为了解决这个问题,您只需要为位于 apps\phpMyadmin\config.ini.php 的系统 phpMyAdmin 配置文件提供正确的密码 1. 根应该已经设置为用户 2. 在“ ”和那它。
If you still have problems then this means that the user name and /or the password need to be updated or inserted into the DB. to do this use the command line tool and do an update.
如果您仍然有问题,那么这意味着需要更新用户名和/或密码或将其插入到数据库中。为此,请使用命令行工具并进行更新。
UPDATE mysql.user SET Password=PASSWORD('Johnny59 or whatever you want to use') WHERE User='root';
UPDATE mysql.user SET Password=PASSWORD('Johnny59 or what you want to use') WHERE User='root';
回答by arokiya
mysql.exe->Run as administrator or go to following path C:\wamp\bin\mysql\mysql5.5.24\bin and than right click on mysql.exe go to properties and than select tab as Compatibility and see the bottom of dialog box in privilege leveland just check the Run this program as an administrator and then click apply ok.finished now you open success phpMyadmin. bye
mysql.exe-> 以管理员身份运行或转到以下路径 C:\wamp\bin\mysql\mysql5.5.24\bin 然后右键单击 mysql.exe 转到属性,然后选择选项卡作为兼容性并查看对话框底部权限级别框中,只需选中以管理员身份运行此程序,然后单击应用确定。完成现在您打开成功 phpMyadmin。再见
回答by Peris
Try the following code:
试试下面的代码:
$cfg['Servers'][$i]['password'] = '';
if you see Password column field as 'No' for the 'root' user in Users Overview
page of phpMyAdmin.
如果您在Users Overview
phpMyAdmin 页面中看到“root”用户的“密码”列字段为“否” 。