mysql 远程 error 2002,远程服务器的phpmyadmin 2002错误

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

Here is my current situation:

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.

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;

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

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.

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.

解决方案

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

On the client side you can run:

getsebool -a | grep httpd_can_network_connect_db

I got the response:

httpd_can_network_connect_db --> off

To change it you can run:

setsebool -P httpd_can_network_connect_db on

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值