SQLSTATE [HY000] [2002]权限被拒绝 [英] SQLSTATE[HY000] [2002] Permission denied
问题描述
我收到此错误,不知道原因
SQLSTATE[HY000] [2002] Permission denied
这是我尝试在其中上传文件example.com
的网站.
I am getting this error don't know the reason
SQLSTATE[HY000] [2002] Permission denied
and here is the website on which i am tryiing to upload my file example.com
.
推荐答案
发生这种情况是因为selinux避免了从httpd服务器到远程数据库服务器的数据库连接.要解决此问题,您需要通过ssh访问服务器,或者如果您具有特权访问权限,则只需打开控制台并执行以下操作:
This happen because selinux avoid db connections from the httpd server to the remote db server. To solve it you need to access your server trough ssh or just open a console if you have pretencial acces and do the follow:
如果管理端口80,则必须检入SELinux.您可以键入# semanage port -l | grep http_port_t
作为列表来检查它,并检查:
You must check in the SELinux if the port 80 is managed in. You can check it typing # semanage port -l | grep http_port_t
for list and check:
http_port_t tcp 443, 488, 8008, 8009, 8443, 9000
如果需要添加所需的端口,只需键入:
If you need to add the required port, just type:
# semanage port -a -t http_port_t -p tcp 80
键入命令再次确认:
# semanage port -l | grep http_port_t
.
http_port_t tcp 80, 443, 488, 8008, 8009, 8443, 9000
然后,应通知SELinux您要允许从httpd服务器到db远程服务器的网络连接,并设置设置它的布尔变量:
Then you should notify SELinux you want to allow network connections from the httpd server to the db remote server, seting the boolean variables that set it:
- 关闭httpd服务
# service httpd stop
-
# setsebool httpd_can_network_connect 1
-
# setsebool httpd_can_network_connect_db 1
- 启动httpd服务
# service httpd start
- Down the httpd service
# service httpd stop
# setsebool httpd_can_network_connect 1
# setsebool httpd_can_network_connect_db 1
- Up the httpd service
# service httpd start
现在,您的httpd服务应该能够从数据库服务器获取数据了.
Now your httpd service should be capable to get data from the db server.
我希望这对搜索解决此类错误的帮派有用.
I hope that can be usefull for the gang that search solve errors like this.
最诚挚的问候.
这篇关于SQLSTATE [HY000] [2002]权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!