Wednesday, October 19, 2016

Re: [google-cloud-sql-discuss] Re: DB_HOST

Hi again,


Thanks for providing details about your environment. Still, I was unable to reproduce your error using a similar setup to yours, mainly consisting of a WordPress website hosted on Compute Engine and linked to a MySQL database on Cloud SQL.


For the reproduction, I used the Cloud Launcher to launch a WordPress solution. After importing a "dump.sql" file (from MySQL database of the WordPress Solution) to a first generation Cloud SQL instance, I followed this guide to successfully connect my WordPress website to the transferred database.


Important steps to note:


1. Generate an IPv4 address on both instances(static IPv4 on GCE) and authorise the one form GCE to connect to the Cloud SQL instance.

2. Create a user account on the Cloud SQL instance under the Access Control tab and set the "Host name" to the GCE's instance static IPv4 or to "Allow any host (%)" for testing purposes.

3. Edit the wp-config.php file in the \var\www\html directory of the Wordpress site on the GCE instance with DB_HOST set to '[Cloud SQL Generated IPv4 address]', and the other variables matching your newly created user and uploaded database name on the Cloud SQL instance.


Note that you can test your Cloud SQL database connection from the GCE instance through SSH on the instance menu and running the GCloud command  "mysql --host=[Cloud SQL Generated IPv4 address] --user=[Created User] --password". This way you can make sure that the uploaded database on Cloud SQL is reachable after having configured a new user, all the IPv4 addresses and authorisation steps. More information can be found on this link.


Concerning the redirect issue, it may be caused by a misconfigured Apache server and so you may want to use external tools such as this one to identify what is causing it.


Let me know if those tips help you to connect to the Cloud SQL database and if you need any additional clarification.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/75ea26dd-6cf4-4e93-a10f-f30d94f28b74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment