添加 root 密码,无法访问 phpmyadmin

发布于 2024-10-08 20:17:33 字数 609 浏览 0 评论 0原文

使用 phpmyadmin,我将用户 root 的密码(本地主机条目和 127.0.0.1 条目)从空白更改为“password”。然后我被锁定在 phpmyadmin 之外,收到 1130 错误:“主机‘localhost’不允许连接到此 MySQL 服务器”

我在 stackoverflow 上进行了大量搜索,找到了一个让我回到 phpmyadmin 的解决方案:

我只需添加将“skip-grant-tables”行添加到“my.ini”的 [mysqld] 部分。

但这似乎是一个糟糕的解决方案,就像我只是在回避问题而不是解决问题。我还尝试了另一种解决方案,将我的用户名和密码添加到本节中的“config.inc.php”:

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'mypass';

但这没有效果。所以我的问题是:

  1. 为什么添加 root 密码会首先将我锁定在 phpmyadmin 之外?难道它不应该让我进入登录屏幕吗?

  2. 解决这个问题的正确方法是什么?

谢谢 约拿

Using phpmyadmin, I changed the password for user root (both the localhost entry and the 127.0.0.1 entry) from blank to "password". I was then locked out of phpmyadmin, getting the 1130 error: "Host ‘localhost’ is not allowed to connect to this MySQL server"

I did a bunch of searching on stackoverflow and found a solution that gets me back into phpmyadmin:

I simply add the line "skip-grant-tables" to the [mysqld] section of "my.ini".

But that seems like a bad solution, like I am just circumventing the problem rather than fixing it. I also tried another solution in which I add my username and password to "config.inc.php" in this section:

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'mypass';

but that has no effect. So my questions are:

  1. Why would adding a password to root lock me out of phpmyadmin in the first place? Shouldn't it just bring me to a login screen?

  2. What is the proper way to fix this?

Thanks
Jonah

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

薄荷港 2024-10-15 20:17:33

我尝试了一些建议的更改来返回 phpMyAdmin,但它们不起作用。然而,在查看配置文件时,我遇到了这样的语句:

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

只需在单引号之间插入 root 用户的密码,然后保存文件即可。你应该能够回来。

I tried several of the suggested changes to get back into phpMyAdmin, and they did not work. However, while going through the config file, I came across this statement:

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

Simply insert the password for the root user between the single quotes, then save the file. You should be able to get back in.

对你的占有欲 2024-10-15 20:17:33

phpma 安装根目录中的 config.inc.php 包含所有配置。

对于身份验证类型,您可能可以在公共服务器上使用 cookie,但如果存在计算机被盗或被潜在有害人员访问的风险,则不行。在我的本地主机上,我只需使用身份验证类型的配置并将我的登录凭据放在那里,这样我就可以完全跳过登录。不适合互联网使用。

祝你好运,圣诞快乐! :D-

汤姆

config.inc.php in the root of your phpma install contains all the configurations.

For the auth type, you could probably get away with cookies on a public server, but not if there's a risk of the computer being stolen or accessed by a potentially harmful person. On my localhost, I just use config for the auth type and place my login credentials in there so I can skip logins entirely. Not ideal for internet use.

Good luck, and merry Christmas! :D

-Tom

听风念你 2024-10-15 20:17:33
  1. 根据您选择的配置,它可以将您完全锁定。
  2. 删除配置文件并重新上传配置向导并创建新配置。
  1. depending on the configuration you chose, it can lock you out completely.
  2. delete the configuration files and reupload the config wizard and create a new configuration.
甩你一脸翔 2024-10-15 20:17:33

配置文件中的行如下所示,它应该可以解决问题。

//$cfg['服务器'][$i]['auth_type'] = 'config';

我所做的只是在行首添加两个正斜杠。这限制了该行的编译和工作。

The line in the config file will look like the following and it should solve the problem.

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

All I did was putting two forward slashes in the beginning of the line. This restricts the line from being compiled and work.

海之角 2024-10-15 20:17:33

不幸的是,当您按照建议注释掉下面的代码时,
//$cfg['Servers'][$i]['auth_type'] = 'config'

结果是身份验证被自动禁用,存在安全风险。我更喜欢卸载并重新安装。

unfortunately, when you comment out the code below as suggested,
//$cfg['Servers'][$i]['auth_type'] = 'config'

the result is that the authentication is automatically disabled and it is a security risk. I prefer uninstalling and re-installation.

阪姬 2024-10-15 20:17:33

我遇到了同样的问题,在 PMA 中收到安全警告后,我决定更改 root 帐户的密码。

我注意到根使用 IPV4 环回地址 (127.0.0.1) 显示 3 次,使用 IPV6 环回地址 (:::1) 一次一次使用本地主机地址...

所以我开始更改所有三个密码,但在第三个之后我被锁定了。

my.ini 中的密码设置(通过 xampp)没有做到这一点,在 config.inc 中设置pwd也没有做到这一点。 php 条目 $cfg['Servers'][$i]['password'] (尽管它是解决方案的一部分)。

然后我将 $cfg['Servers'][$i]['host'] 设置从 127.0.0.1 更改为 localhost 并瞧!我回来了!

我不知道为什么这会起作用,因为 localhost 应该被转换为 127.0.0.1,但我希望这也能对其他人有所帮助。

I had the same problem, after getting the security warnings in PMA I decided to change the password for the root account(s).

I noticed the root is displayed 3 times once with the IPV4 loop-back address (127.0.0.1), once with the IPV6 loop-back address (:::1) and once with the localhost address...

So I started changing passwords on all three, but after the third I got locked out.

Password setting in my.ini (through xampp) didn't do it, neither did setting the pwd in config.inc.php entry $cfg['Servers'][$i]['password'] (though it is part of the solution).

And then I changed the $cfg['Servers'][$i]['host'] setting from 127.0.0.1 to localhost and voilà! I got back in!

I don't have a clue why this worked, as localhost is supposed to get translated to 127.0.0.1, but I hope this also helps some others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文