phpMyAdmin - 什么'下一个配置有误吗?

发布于 2024-09-19 02:33:46 字数 936 浏览 3 评论 0原文

尝试在我的 Fedora 服务器上安装 phpMyAdmin,但是如果我在浏览器中打开它,我会收到下一个错误:

2002 无法登录到 MySQL 服务器

文件 config.inc.php 有下一个内容:

<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$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'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123';


/* End of servers configuration */

$cfg['blowfish_secret'] = '4c45c50fe8b283.01675296';
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

只是添加,在 mysql 中我创建了用户 root ,密码为 123,这样我就可以登录:

mysql -h localhost -u root -p123

你能帮我看看问题出在哪里吗?

tryin to install phpMyAdmin on my Fedora server, but if i open it in browser, i get next error:

2002 Cannot log in to the MySQL server

file config.inc.php have next content:

<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$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'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123';


/* End of servers configuration */

$cfg['blowfish_secret'] = '4c45c50fe8b283.01675296';
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

just to add, in mysql i created user root, with password 123, so i can log in with:

mysql -h localhost -u root -p123

can you help me where is the problem?

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

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

发布评论

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

评论(2

乖不如嘢 2024-09-26 02:33:46

mysql -h localhost 实际上通过 unix 套接字 而不是到 127.0.0.1 的 TCP 连接。另一方面,显式指定 mysql -h 127.0.0.1 确实使用 TCP 方法。

所以你正在测试的是本地套接字连接,而不是网络连接。确保 phpMyAdmin 使用相同的方法;该行

$cfg['Servers'][$i]['connect_type'] = 'tcp';

可能应该显示

$cfg['Servers'][$i]['connect_type'] = 'socket';

您的 mysqld 可能有 网络已禁用或用户权限拒绝从网络进行 root/123 访问。

在您的示例中使用 -h localhost 您实际上是通过命名套接字进行连接。您可以亲自查看 - 从 mysql 客户端输入“\s”:

mysql> \s
--------------
(....)
Connection:     Localhost via UNIX socket

mysql -h localhost actually connects via unix socket instead of a TCP connection to 127.0.0.1. Explicitly specifying mysql -h 127.0.0.1 on the other hand does use the TCP method.

So what you are testing is a local socket connection, not a network one. Make sure phpMyAdmin uses the same method; the line

$cfg['Servers'][$i]['connect_type'] = 'tcp';

should probably read

$cfg['Servers'][$i]['connect_type'] = 'socket';

Your mysqld probably has either networking disabled or user permissions denying root/123 access from the network.

With -h localhost in your example you are actually connecting over a named socket. You can see for yourself - from the mysql client type "\s":

mysql> \s
--------------
(....)
Connection:     Localhost via UNIX socket
望她远 2024-09-26 02:33:46

好的,我解决了。

在配置文件中,我刚刚将“localhost”更改为“127.0.0.1”,它就开始工作了。

tnx anw!

ok, i solve it.

in configuration file, i just changed 'localhost' to '127.0.0.1', and it started to work.

tnx anw!

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