Hello,
I am developing a Google API that will be accessible on a Wordpress site.
I have been working on Wordpress for a long, but I never had the need to pre-develop on a Google Cloud Service.
So it's my first time with Google Cloud 😁.
I have created a project in Google Cloud, I have downloaded all files from my Wordpress live server (all files and credentials are correct), and I haved uploaded them via Cloud Shell.
I have also created a MySQL database wich is connected to the correct instance (my project id).
Yet, when I click on Web Preview, en error message says : Error establishing a database connection.
I guess there is a problem with credentials, here is what I did :
After I created a DB on Google Cloud, I opened my wp-config.php to change the old DB name and password, as wp-config.php was containing the credentials for the DB that is actually on the live site.
Here is the part of wo-config.php where I changed the credentials :
_____________________________
/** The name of the database for WordPress : I changed it to the name for the newly created DB */
define( 'DB_NAME', 'new_name' );
/** Database username I didn't change the user name*/
define( 'DB_USER', 'old_user_name' );
/** Database password I changed the password*/
define( 'DB_PASSWORD', 'XXXXX );
____________________________________
However, I didn't input the new Data base User name, could it be the reason why I can't connect to the Data base ? If so, where can I find my Google Data base user name ?
Morover, I navigated to My SQL On Google Cloud, I clicked "To connect using Gcloud Open Cloud Shell". It indeed open Cloud Shell and generated a cmd that says :
xxx@cloudshell:~ (my-project-id)$ gcloud sql connect database_name --user=root --quiet
However, when I click on Web Preview, I still see : error establishing a database connection.
Can anyone tell me what I did wrong ?
Thank you very much in advance.
Hi @healthy_mind,
Welcome to the Google Cloud community!
You might be onto something with the username issue. When you create a MySQL instance, the default user is usually 'root'@'%'
. If you're not sure about how to configure this user, you can check out the Configure the default user account guide for more details.
If you're still stuck, the Debugging connection issues page or the Connectivity section in the troubleshooting page could be really helpful for narrowing down the problem.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.