1

I just installed Magento 2.1.9 on CentOS 7.4. I have configured MySql 5.7.17. I am using the web-based Setup Wizard.

On the step for 'Add a Database' I get the error

SQLSTATE[HY000] [2002] Permission denied

My MySql server is on a separate host from my Magento2. I am able to connect to the MySql server using command line from the Magento2 server.

How can I get past this error in the web-based Setup Wizard?

mysql> SHOW GRANTS FOR CURRENT_USER;
+------------------------------------------------------+
| Grants for magento@%                                 |
+------------------------------------------------------+
| GRANT USAGE ON *.* TO 'magento'@'%'                  |
| GRANT ALL PRIVILEGES ON `magento`.* TO 'magento'@'%' |
+------------------------------------------------------+
2 rows in set (0.01 sec)
3
  • 1
    Database and user which you are using is having all rights on database ? Sep 28, 2017 at 4:05
  • Yes. I have updated the original post with the details of privileges. The user has all privileges.
    – Ali
    Sep 28, 2017 at 4:12
  • 1
    stackoverflow.com/a/44092808/7472487 check this post once. Sep 28, 2017 at 4:16

1 Answer 1

3

The issue turned out to be the SELinux security policies.

By default, the policy httpd_can_network_connect_db is disabled (meaning that your web server cannot contact a remote DB.)

You can check this using:

getsebool -a | grep httpd

in case httpd_can_network_connect_db is Off, then you can enable using:

setsebool -P httpd_can_network_connect_db 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.