为什么phpmyadmin拒绝通过本地主机连接,但接受127.0.0.1?(Why phpmyadmin refuses to connect over localhost but accepts 1

系统教程 行业动态 更新时间:2024-06-14 17:03:54
为什么phpmyadmin拒绝通过本地主机连接,但接受127.0.0.1?(Why phpmyadmin refuses to connect over localhost but accepts 127.0.0.1?)

我只是将我的Mac更新到10.13并重新安装了我的开发工具。 在设置phpmyadmin时,无法使用以下命令连接到mysql:

$cfg['Servers'][$i]['host'] = 'localhost';

phpmyadmin抛出:

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

相反,我不得不使用它来工作:

$cfg['Servers'][$i]['host'] = '127.0.0.1';

在过去,我可以离开默认的“本地主机”,并没有问题,但它不会再通过套接字连接。

我的mysql用户是'root'@'localhost',使用最新的mysql,apache,phpmyadmin。

可能是什么原因? 谢谢

I just updated my mac to 10.13 and reinstalled my dev tools. While setting up phpmyadmin it was unable to connect to mysql using:

$cfg['Servers'][$i]['host'] = 'localhost';

phpmyadmin throws:

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.

instead I had to use to get it working:

$cfg['Servers'][$i]['host'] = '127.0.0.1';

In the past I could leave the default "localhost" and had no issues but it won't connect via socket any more.

My mysql user is 'root'@'localhost', using latest mysql, apache, phpmyadmin.

What could be the reason? Thanks

最满意答案

可能有一个以上的理由发生,同样的问题也在这个问题上讨论过。 我建议您阅读此问题提供的答案,以根据您所持有的环境解决错误。

这是ServerFault的问题 !

我倾向于在开发环境中看到的常见问题是:

您可能启用了IPv6 ,它的非常可能的本地主机解析为IPv6本地主机,它未在您的MySQL配置中定义。

Thanks to @N00b Pr0grammer's suggestion, I went trough the different solution still I figured it out.

On fresh installs of OS X, php.ini is turned off, and by default looks for mysqli.default_socket at "/var/mysql/mysql.sock" so I had to 1. rename php.ini.default to php.ini than 2. set:

mysqli.default_socket = /tmp/mysql.sock

and restart apache. Now phpmyadmin is able to connect to mysql via localhost as well.

更多推荐

本文发布于:2023-04-24 14:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/3c7befdda873134c643c7d467d5256a4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机   phpmyadmin   localhost   accepts   refuses

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!