0

I have a Google Cloud Platform Compute Engine VM instance where I have Apache installed. I wanted to put WordPress on here and have the MySQL database created locally instead of using another GCP Resource API.

I've finished installing MySQL locally and created a database and user and granted access as well. But when I try installing WordPress I get this error:

Error establishing a database connection

This 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 localhost. This could mean your host’s database server is down.

I've read that I might need to add the mysql-server tag to my VM instance and add a firewall rule to allow TCP 3306 which I have now set up. But when I retry WordPress it still gives the same error. I also tried using my static external IP address when trying to connect WordPress to the database but no dice. I don't know how else to troubleshoot this.

Also, if it helps, I installed MySQL 8.

2 Answers 2

1

MySQL 8.x is actually ‘IS’ supported, but requires a slightly different command when creating the user and password, as version 8 expects passwords to be SHA256 encoded.

When creating the database user, with the MySQL prompt, use the following:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

So WITH mysql_native_password being the main difference.

To troubleshoot the case you can also check out this link

0

Have you setup the mysql instance? On RHEL, try a mysql_secure_install to configure it, systemctl start mysql and systemctl enable mysql

Is your database running?

systemctl status mysql ss -ln netstat -lapton | grep 3306

2
  • systemctl status mysqld shows that it's active and running.
    – dokgu
    Aug 31, 2021 at 3:36
  • what does netstat -platon show? Sep 2, 2021 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .