• I’m new to wordPress so please forgive me if this has been answered before.

    I’ve two CentOS 7.4 Servers.
    – CentOS-DB-01 10.60.161.173 255.255.255.192 with MySQL 8.0 installed
    – CentOS-Web-01 10.60.161.231 255.255.255.192 running Apache

    I’ve followed the documentation to install WordPress but, when attempting to complete the WordPress installation through the Web Browser, I get the following

    Error establishing a database connection
    his either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at 10.60.161.173. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?

    MySQL is running and i’ve checked the wp-config.php file, it seems to be ok.
    I’m also able to Ping between the two Servers so, Routing is working.

    Any help would be appreciated.
    Thanks,
    Jason

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Do you allow remote connections to your mysql server or are you blocking port 631 at the firewall?

    If you try, on the server hosting WordPress

    mysql -u DB_USER -pDB_PASSWORD -h DB_HOST DB_NAME

    from the command line (substituting the DB values from wp-config.php) does that work?

    Also, on the mysql server, is the server set to accept remote connections? What is the “bind-address” in /etc/my.cnf.d/server.cnf (or mariadb-server.cnf).

    Thread Starter piercj2

    (@piercj2)

    Thanks for the reply Steve,

    Unfortunately, WordPress is installed on my CentOS-Web-01 server and MySQL is installed on my CentOS-DB-01 Server. As a result, running the MySQL command on the WordPress server, returns the error “bash: mysql: command not found…”

    If however I run the command on the MySQL Server, I successfully enter MySQL so it looks like i’ve the User Credentials entered into /var/www/html/wp-config.php correctly

    To your last point, the content of /etc/my.cnf.d/server.cnf in the MySQL server is blank.
    looks like I need to allow the Server acceptremote connections but, haven’t done this before (also new to CentOS).
    Looks like i’m of to Google again 🙂

    Thanks again for the assist,
    Jason

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Install the mysql client on your web server!

    Thread Starter piercj2

    (@piercj2)

    Hi Steve
    Not sure if i’m looking in the correct file but, the contents of /etc/my.cnf are

    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    bind_address=10.60.161.173

    10.60.161.173 is the IP of CentOS-DB-01, where MySQL is installed

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    That should be good; now see if you can access it from the other server. Also, check your firewall to make sure port 631 is open.

    Thread Starter piercj2

    (@piercj2)

    I couldn’t install a mysql-client on the CentOS 7.4 WordPress server so I installed MariaDB-client instead.
    issuing the “mysql -u wp_svc -p wordpress -h 10.60.161.173” command from the WordPress server returns
    “ERROR 2059 (HY000): Authentication plugin ‘caching_sha2_password’ cannt be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory”

    On the Database Server, i’ve also edited /etc/my.cnf and set the port to 3306
    I’ve set the following iptables rules
    iptables -A INPUT -i 1o -p tcp –dport 3306 -j ACCEPT
    iptables -A OUTPUT -p tcp –dport 3306 -j ACCEPT

    I also disabled the firewall on the Database Server with
    systemctl disable firewalld.service
    systemctl stop firewalld.service

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    3306! Yeah, sorry about the 631. I’ve been debugging a CUPS issue today and it was on my mind.

    Are you also using iptables on the DB server?

    It’s pretty clear, though, that this is a system problem and not a WP problem.

    Thread Starter piercj2

    (@piercj2)

    thanks Steve,
    On both servers i’ve set iptables to accept all inbound and outbound traffic with
    – iptables -A INPUT -j ACCEPT
    – iptables -A OUTPUT -j ACCEPT

    Still unable to connect to the database from the Web Server.

    I understand what you’re saying about it probably being a System issue rather than a WordPress issue. I’ll keep Googling to see what I can find. Thanks again,
    Jason

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.