php 使用 PHPMyAdmin 拒绝用户“root”@“localhost”的访问

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

Access denied for user 'root'@'localhost' with PHPMyAdmin

phpmysqlphpmyadminwampserver

提问by Sam

When I set the root password in PHPMyAdmin, I get this error:

当我在 PHPMyAdmin 中设置 root 密码时,出现此错误:

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

I can't open the PHPMyAdmin panel. What am I doing wrong?

我无法打开 PHPMyAdmin 面板。我究竟做错了什么?

回答by Sathishkumar

Edit your phpmyadmin config.inc.php file and if you have Password, insert that in front of Password in following code:

编辑您的 phpmyadmin config.inc.php 文件,如果您有密码,请在以下代码中将其插入密码前:

$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'] = 'config';
$cfg['Servers'][$i]['user'] = '**your-root-username**';
$cfg['Servers'][$i]['password'] = '**root-password**';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

回答by Khadka Pushpendra

Here are few steps that must be followed carefully

以下是必须仔细遵循的几个步骤

  1. First of all make sure that the WAMP server is running if it is not running, start the server.
  2. Enter the URL http://localhost/phpmyadmin/setupin address bar of your browser.
  3. Create a folder named config inside C:\wamp\apps\phpmyadmin, the folder inside apps may have different name like phpmyadmin3.2.0.1

  4. Return to your browser in phpmyadmin setup tab, and click New server.New server

  5. Change the authentication type to ‘cookie' and leave the username and password field empty but if you change the authentication type to ‘config' enter the password for username root.

  6. Click save save

  7. Again click save in configuration file option.
  8. Now navigate to the config folder. Inside the folder there will be a file named config.inc.php. Copy the file and paste it out of the folder (if the file with same name is already there then override it) and finally delete the folder.
  9. Now you are done. Try to connect the mysql server again and this time you won't get any error. --credits Bibek Subedi
  1. 首先确保WAMP服务器正在运行,如果没有运行,启动服务器。
  2. 在浏览器的地址栏中输入 URL http://localhost/phpmyadmin/setup
  3. 在 C:\wamp\apps\phpmyadmin 中创建一个名为 config 的文件夹,apps 中的文件夹可能有不同的名称,如 phpmyadmin3.2.0.1

  4. 返回到 phpmyadmin 设置选项卡中的浏览器,然后单击新建服务器。新服务器

  5. 将身份验证类型更改为“cookie”并将用户名和密码字段留空,但如果将身份验证类型更改为“config”,请输入用户名 root 的密码。

  6. 点击保存 节省

  7. 再次单击保存在配置文件选项中。
  8. 现在导航到配置文件夹。在文件夹内会有一个名为 config.inc.php 的文件。复制文件并将其粘贴到文件夹外(如果同名文件已经存在,则覆盖它),最后删除该文件夹。
  9. 现在你完成了。尝试再次连接 mysql 服务器,这次您不会收到任何错误。--credits Bibek Subedi