MySQL Wamp phpMyAdmin 错误 #1045 - 用户 'root'@'localhost' 拒绝访问

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

Wamp phpMyAdmin error #1045 - Access denied for user 'root'@'localhost'

mysqlphpmyadminwamproot

提问by MateuszC

This is quite common problem and I found a lot of tutorials to help me solve it, although, there is one additional problem with my case...

这是一个很常见的问题,我找到了很多教程来帮助我解决它,但是,我的案例还有一个额外的问题......

This is my config settings in config.inc.php

这是我在 config.inc.php 中的配置设置

$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;

When I try to log in via wamp main page, the error shows:

当我尝试通过 wamp 主页登录时,错误显示:

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

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

AND this same is when I try to acces MyAdmin by CONSOLE!

当我尝试通过控制台访问 MyAdmin 时也是如此!

No matter what I type as password or just press enter, it shows me this same error, and because of that i cant 'flush priviliges'.

无论我输入什么密码或只是按回车键,它都会向我显示同样的错误,因此我无法“刷新特权”。

What can I do?

我能做什么?

回答by Chanaka Karunarathne

Step 1: Open your MySQL console.

第 1 步:打开您的 MySQL 控制台。

Step 2: Enter the Provided Command Lines

步骤 2:输入提供的命令行

$use mysql;
$UPDATE mysql.user SET password="PASSWORD("YourPassword") WHERE user="root";
$FLUSH PRIVILEGES;
$exit;

$ use mysql;
$ UPDATE mysql.user SET password="PASSWORD("YourPassword") WHERE user="root";
$ FLUSH PRIVILEGES;
$exit;

Step 3: Open and edit your config.inc.php file located in your local server files

第 3 步:打开并编辑位于本地服务器文件中的 config.inc.php 文件

  1. Go to My Computer > C Drive > ( Your Local Server Folder, WAMP/MAMP/XAMPP ) > APPS > PHPMYADMIN > config.inc.php
  2. Using a text editor, such as Notepad++, open your config.inc.php file.
  3. Find this line of code: $cfg['Servers'][$i]['password'] = ''; // MySQL password
  4. Change ['password'] = ''; --to--> ['password'] = 'YourPassword'; with the new chosen password you created from Step 2.
  5. Click Save
  1. 转到我的电脑 > C 盘 >(您的本地服务器文件夹,WAMP/MAMP/XAMPP)> 应用程序 > PHPMYADMIN > config.inc.php
  2. 使用文本编辑器(例如 Notepad++)打开 config.inc.php 文件。
  3. 找到这行代码:$cfg['Servers'][$i]['password'] = ''; // MySQL 密码
  4. 更改 ['密码'] = ''; --to--> ['密码'] = '你的密码'; 使用您在步骤 2 中创建的新密码。
  5. 点击保存

Step 4: Go to phpmyadmingo to http://localhost/phpMyAdmin/.

第 4 步:转到 phpmyadmin转到http://localhost/phpMyAdmin/.

回答by Javi Ps

Change the line:

更改行:

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

to

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

Restart and you will be asked for the password the next access to the phpmyadmin page

重新启动,下次访问 phpmyadmin 页面时将要求您输入密码

回答by RiggsFolly

Did you add a password to the MySQL 'root' userid?

您是否为 MySQL 的“root”用户 ID 添加了密码?

If not, by default it comes without a password. So use

如果没有,默认情况下它没有密码。所以用

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

and remove this its a defunct parameter since phpMyAdmon 3.2.0

并删除它自 phpMyAdmon 3.2.0 以来已失效的参数

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

回答by Ankit Pandey

Try username = root and password is blank.

尝试 username = root 和密码为空。

回答by man on edge

go to control panel > administrative tool> service >

control panel > administrative tool> service >

then you will find a list of items , navigate to MYSQL

然后你会找到一个项目列表,导航到 MYSQL

right click on its properties, in general tabstart type make it automatic

右键单击它properties,在general tab开始类型make it automatic

then apply / save

然后 apply / save

and finally restart all services in wamp

最后 restart all services in wamp

回答by Chris

after changing the root password you must first enter the following in mysql console:

更改root密码后,您必须首先在mysql控制台中输入以下内容:

FLUSH PRIVILEGES;

同花顺特权;

before the changes will take effect

在更改生效之前

Do this by openening a terminal/command console and navigating to your mysql.exe example: C:\wamp\bin\mysql\mysql5.5.24\bin\mysql -u YOURUSERNAMEHERE -p

通过打开终端/命令控制台并导航到您的 mysql.exe 示例来执行此操作: C:\wamp\bin\mysql\mysql5.5.24\bin\mysql -u YOURUSERNAMEHERE -p

If you have fiddled with your root account and can no longer access it see the following link for resetting your root account:

如果您弄乱了您的 root 帐户并且无法再访问它,请参阅以下链接以重置您的 root 帐户:

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

After this it should work fine as per your config.inc.phpfile

在此之后,它应该可以根据您的config.inc.php文件正常工作

回答by debika sadhukhan

On the MySQL error page, where two pink coloured error panels are appeared, you can find a small button at right side there. click on it.

在 MySQL 错误页面上,出现两个粉红色错误面板,您可以在右侧找到一个小按钮。点击它。