本文介绍了PHP MySQLi查询-“权限被拒绝"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP MySQLi连接到MySQL,有时会执行查询,但出现错误:

Im using PHP MySQLi to connect to MySQL and sometimes doing query i get error:

奇怪的是,它发生在不同的查询中并且完全不可预测.例如,它可能在正确执行前两个查询后的第三个查询上发生.

The strange thing is that it happens for different query's and totally unpredictable. For example it might happen on third query after first two executed correctly.

我知道MySQL没问题,因为我将它从一台服务器移到了另一台服务器,并且问题仍然存在. PHP或PHP与MySQL服务器之间的互连(它们位于不同的机器上)很可能是问题

I know it is not problem with MySQL because i moved it from one server to another and problem still persists. Most likely problem with PHP or interconnection between PHP and MySQL servers (they're on different machines)

有人知道吗?


查询如果我重新启动脚本,得到权限被拒绝"的内容的原因-它不是权限问题


query what gets "Permission denied" works if i restart script - its not permissions problem

错误:

推荐答案

我的环境中发生了同样的事情.原因是SELinux.

Same things happened on my environment. And the cause was SELinux.

您也许可以通过从命令行执行php来连接数据库虽然您可能无法通过在Web服务器上执行.

You might be able to connect the database by executing php from command linewhile you might not by executing on the web server.

就我而言,我关闭了SELinux.

In my case, I turned off SELinux.

# setenforce 0

或者您必须正确设置SELinux.

Or you have to set up SELinux correctly.

这篇关于PHP MySQLi查询-“权限被拒绝"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:38
查看更多