远程服务器的phpmyadmin 2002错误 [英] phpmyadmin 2002 error for remote server

查看:213
本文介绍了远程服务器的phpmyadmin 2002错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的情况,涉及phpMyAdmin试图连接到远程数据库服务器.请注意,所有机器都在运行CentOS 7.

I have a really weird situation involving phpMyAdmin trying to connect to a remote DB server. Note that all machines are running CentOS 7.

这是我目前的情况:

  • 我有一台mariadb 10.2服务器,临时设置了'root'@'%'登录名.
  • 我有两个安装了phpMyAdmin的Web服务器(我们叫它们Client1和Client2).
  • 我可以从Client1上的phpMyAdmin访问mariadb服务器,但不能在Client2上访问.
  • Client1和Client2的phpMyAdmin服务器配置相同.
  • 在client2上,我能够通过mysql命令成功访问mariadb服务器.
  • 我在client2上设置了mariadb服务器,并且phpMyAdmin能够很好地登录到本地主机.
  • I have a mariadb 10.2 server with a 'root'@'%' login temporarily set up.
  • I have two web servers set up with phpMyAdmin installed (Let's call them Client1 and Client2).
  • I can access the mariadb server from phpMyAdmin on Client1 but not on Client2.
  • The phpMyAdmin server config is identical for both Client1 and Client2.
  • On client2 I am able to successfully access the mariadb server through the mysql command.
  • I set up a mariadb server on client2 and phpMyAdmin is able to login to localhost just fine.

这是我的/etc/phpMyAdmin/config.inc.php,其中删除了个人信息

Here is my /etc/phpMyAdmin/config.inc.php with personal info removed

$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'mypass';
$cfg['Servers'][$i]['host'] = '1.2.3.4';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;

以下是phpMyAdmin向我显示的错误:

Here are the errors that phpMyAdmin shows me:

#2002 - Permission denied — The server is not responding (or the local server's socket is not correctly configured)

mysqli_real_connect(): (HY000/2002): Permission denied

我已经在本地client2机器上重新安装了mariadb并在config.inc.php中手动设置了套接字值,但这似乎无法解决任何问题.

I have re-installed mariadb on the local client2 machine and manually set the socket value in config.inc.php but that doesn't seem to fix anything.

即使phpMyAdmin失败,以下命令也可以从Client2计算机正常连接:
mysql -u root -h 1.2.3.4 -pmypass

The following command connects just fine from the Client2 machine even though phpMyAdmin fails:
mysql -u root -h 1.2.3.4 -pmypass

我现在不知道如何缩小搜索范围.

I'm just not sure how to narrow my search for the issue at this point.

推荐答案

答案很愚蠢但很简单,问题是SElinux,而不是数据库服务器,而是客户端.

Well the answer was stupid but simple, SElinux was the issue, and not on the Database server but on the client side.

在客户端,您可以运行:
getsebool -a | grep httpd_can_network_connect_db

On the client side you can run:
getsebool -a | grep httpd_can_network_connect_db

我得到了答复:
httpd_can_network_connect_db --> off

I got the response:
httpd_can_network_connect_db --> off

要更改它,可以运行:
setsebool -P httpd_can_network_connect_db on

To change it you can run:
setsebool -P httpd_can_network_connect_db on

一旦我完成了phpMyAdmin的连接,就立即刷新页面.

Once I had done that phpMyAdmin connected right away on a page refresh.

我不知道SELinux将停止传出连接:(

I had no idea that SELinux would stop outgoing connections :(

这篇关于远程服务器的phpmyadmin 2002错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆