• Resolved dzarelli

    (@dzarelli)


    Hello – I’ve been searching for information but I’ve not found a solution to this one.

    I am standing up a wordpress instance in Amazon AWS. We have an RDS instance of MySQL 5.7 running and we configured Route53 with a friendly DNS name. We’ll call it blogtest-db.mydomain.com. Now, I have WordPress files copied to /var/www/html and I’m getting the ‘database connection details’ setup screen. I have added the wordpresstest user to MySQL with full privileges. When complete the setup using db name: wordpresstest, username: wordpresstest, using the correct password, database host: blogtest-db.mydomain.com. I get “Error establishing a database connection”. I’ve tried both with and without adding :3306 to the DB hostname. No dice.

    However, if I ssh to the wordpress host IP I am able to use mysql to connect to the RDS instance using all of the above information.

    I’m pulling my hair out here trying to figure this out. Any help is greatly appreciated. Thanks!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Since the WordPress host SSH & MySQL remote connection to the RDS host worked fine, it would then point towards the webserver & PHP configuration that may have some issue.

    Here are some points I would suggest to debug a bit more on the issue,
    1. Could you check if the PHP mysqli module is installed & configured correctly? Check the phpinfo and probably try installing and configuring a local MySQL server on the same host to confirm if all is well there.

    2. Try writing a small PHP script (using something like this) to check if the PDO connection from the WP PHP host to RDS works.

    Thread Starter dzarelli

    (@dzarelli)

    Thank you for the response. I think I have all the required php modules installed. PHP musqli looks like it’s installed. I ran a yum update and restarted things to see if that helped, but I’m still hitting the same issue. I ran the php script and it’s returning “Connection failed: Permission denied” however, from the same host, if I run “mysql -h blogtest-db.mydomain.com -u wordpresstest -p”, and use the same password I just specified in the script, I get access. Any thoughts on that? Below is the summary from my phpinfo if it helps. Thanks for helping out! I really appreciate it.

    System	Linux ip-10-144-252-147.us-west-2.compute.internal 3.10.0-862.3.2.el7.x86_64 #1 SMP Mon May 21 23:36:36 UTC 2018 x86_64
    Build Date	Oct 22 2019 11:28:54
    Server API	Apache 2.0 Handler
    Virtual Directory Support	disabled
    Configuration File (php.ini) Path	/etc/opt/remi/php72
    Loaded Configuration File	/etc/opt/remi/php72/php.ini
    Scan this dir for additional .ini files	/etc/opt/remi/php72/php.d
    Additional .ini files parsed	/etc/opt/remi/php72/php.d/10-opcache.ini, /etc/opt/remi/php72/php.d/20-bz2.ini, /etc/opt/remi/php72/php.d/20-calendar.ini, /etc/opt/remi/php72/php.d/20-ctype.ini, /etc/opt/remi/php72/php.d/20-curl.ini, /etc/opt/remi/php72/php.d/20-dom.ini, /etc/opt/remi/php72/php.d/20-exif.ini, /etc/opt/remi/php72/php.d/20-fileinfo.ini, /etc/opt/remi/php72/php.d/20-ftp.ini, /etc/opt/remi/php72/php.d/20-gd.ini, /etc/opt/remi/php72/php.d/20-gettext.ini, /etc/opt/remi/php72/php.d/20-iconv.ini, /etc/opt/remi/php72/php.d/20-json.ini, /etc/opt/remi/php72/php.d/20-ldap.ini, /etc/opt/remi/php72/php.d/20-mbstring.ini, /etc/opt/remi/php72/php.d/20-mysqlnd.ini, /etc/opt/remi/php72/php.d/20-pdo.ini, /etc/opt/remi/php72/php.d/20-phar.ini, /etc/opt/remi/php72/php.d/20-posix.ini, /etc/opt/remi/php72/php.d/20-shmop.ini, /etc/opt/remi/php72/php.d/20-simplexml.ini, /etc/opt/remi/php72/php.d/20-sockets.ini, /etc/opt/remi/php72/php.d/20-sqlite3.ini, /etc/opt/remi/php72/php.d/20-sysvmsg.ini, /etc/opt/remi/php72/php.d/20-sysvsem.ini, /etc/opt/remi/php72/php.d/20-sysvshm.ini, /etc/opt/remi/php72/php.d/20-tokenizer.ini, /etc/opt/remi/php72/php.d/20-xml.ini, /etc/opt/remi/php72/php.d/20-xmlwriter.ini, /etc/opt/remi/php72/php.d/20-xsl.ini, /etc/opt/remi/php72/php.d/30-mcrypt.ini, /etc/opt/remi/php72/php.d/30-mysqli.ini, /etc/opt/remi/php72/php.d/30-pdo_mysql.ini, /etc/opt/remi/php72/php.d/30-pdo_sqlite.ini, /etc/opt/remi/php72/php.d/30-wddx.ini, /etc/opt/remi/php72/php.d/30-xmlreader.ini, /etc/opt/remi/php72/php.d/30-xmlrpc.ini, /etc/opt/remi/php72/php.d/40-zip.ini, /etc/opt/remi/php72/php.d/50-mysql.ini
    PHP API	20170718
    PHP Extension	20170718
    Zend Extension	320170718
    Zend Extension Build	API320170718,NTS
    PHP Extension Build	API20170718,NTS
    Debug Build	no
    Thread Safety	disabled
    Zend Signal Handling	enabled
    Zend Memory Manager	enabled
    Zend Multibyte Support	provided by mbstring
    IPv6 Support	enabled
    DTrace Support	available, disabled
    Registered PHP Streams	https, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
    Registered Stream Socket Transports	tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
    Registered Stream Filters	zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*
    Thread Starter dzarelli

    (@dzarelli)

    Additional content from my phpinfo. Sorry I forgot this on the last post and I can’t seem to edit it.

    Apache Version	Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.24
    Apache API Version	20120211
    Server Administrator	root@localhost
    Hostname:Port	ip-10-144-252-147.us-west-2.compute.internal:443
    User/Group	apache(48)/48
    Max Requests	Per Child: 0 - Keep Alive: on - Max Per Connection: 100
    Timeouts	Connection: 60 - Keep-Alive: 5
    Virtual Server	Yes
    Server Root	/etc/httpd
    Loaded Modules	core mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_dumpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_wstunnel mod_ssl mod_systemd mod_cgi mod_php7
    • This reply was modified 5 years, 1 month ago by dzarelli.
    Thread Starter dzarelli

    (@dzarelli)

    I’ve resolved this issue. It was SELinux. It has to be enabled in our environment so we had to add a boolean. Alternatively if we didn’t need/want it enabled, simply disabling SELinux would’ve solved the issue as well –
    FYI – The commands to enable/disable SELinux are below
    enable:
    setenforce 1
    disable:
    setenforce 0

    A good way to test is to simple turn it off and try to run the wordpress setup wizard. If you can connect finish the setup and re-enable SELinux. If SELinux is the culprit, you will get an error establishing database connection error when you re-enable it.

    It’s probably important to note that SELinux provides important safety features and disabling it is kind of the lazy way to address the issue.
    I found this article that helped.
    https://techblog.jeppson.org/2016/10/install-wordpress-centos-7/

    and here is more information regarding SELinux and using booleans.
    https://wiki.gentoo.org/wiki/SELinux/Tutorials/Using_SELinux_booleans

    I hope this saves someone some time one day.

    • This reply was modified 5 years, 1 month ago by dzarelli.
    • This reply was modified 5 years, 1 month ago by dzarelli.

    Go to EC2 Dashboard.
    Go to Security Groups tab.
    Select and only select the RDS database security group. You’ll see the security group detail at the bottom.
    Click Inbound tab.
    Click Edit button.
    Add Type:MYSQL/Aurora;Protocol:TCP;Range:3306;Source:0.0.0.0/0.
    https://bit.ly/2MIjEjD

    Hi,

    I am basically having the same issue, but have yet to resolve it. We enabled SELinux as @dzarelli suggested but no luck.

    The permissions are GRANT ALL PRIVILEGES ON databasename.* TO username@localhost so they appear to be correctly configured.

    noce

    (@justcleaning)

    nice info

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cannot connect to RDS MySQL DB’ is closed to new replies.