Score:0

WordPress unable to connect to MySQL from GCP Compute Engine VM

gb flag

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.

Score:1
ve flag

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

Score:0
ph flag

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

dokgu avatar
gb flag
`systemctl status mysqld` shows that it's active and running.
JohnnyShivers avatar
ph flag
what does `netstat -platon` show?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.