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
.
-
1You will have to change/set the MYSQL database userid and password in your app, to match what you or your hosting company set them to – RiggsFolly Jan 8 '16 at 9:37
-
3Please read What topics can I ask about and How to ask a good question And the perfect question – RiggsFolly Jan 8 '16 at 9:37
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:
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
Type the command to ckeck once again:
# semanage port -l | grep http_port_t
.
http_port_t tcp 80, 443, 488, 8008, 8009, 8443, 9000
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:
- 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
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.
From Chile, best regards.
-
5Worked for me, but after a reboot, these settings will go away. You will need to permanently make them by using the -P switch like # setsebool -P httpd_can_network_connect 1 – tatorface Oct 10 '18 at 18:38
-
1
Go in .env file and change DB_HOST=127.0.0.1 to DB_HOST=localhost
-
1This seems like the socket / UNIX issue, localhost works on socket while 127.0.0.1 works on tcp – Bsienn Apr 26 '19 at 13:10
May I am late to answer this question but what worked for me are the commands. I ran into same issue and then I ran the following commands.
Provide permissions:
chmod -R 777 .
(though not recommended)
Run setup upgrade command
php bin/magento setup:ugrade
and finally compile command
php bin magento setup:di:compile
Maybe you need to shut down your selinux just like this
setenforce 0
-
2
-