Trying to run Wordpress on Google App Engine with Google SQL Cloud

Warning: mysql_connect(): MySQL server has gone away in /base/data/home/apps/s~vidaaoblog/wp.372917300827551979/wordpress/wp-includes/wp-db.php on line 1147

Warning: mysql_connect(): Error while reading greeting packet. PID=-1 in /base/data/home/apps/s~vidaaoblog/wp.372917300827551979/wordpress/wp-includes/wp-db.php on line 1147

Warning: mysql_connect(): MySQL server has gone away in /base/data/home/apps/s~vidaaoblog/wp.372917300827551979/wordpress/wp-includes/wp-db.php on line 1147

Getting these errors with everything.

WP_CONFIG:

define('DB_NAME', 'wordpress_db');

/** MySQL database username */
define('DB_USER', 'wp_user');

/** MySQL database password */
define('DB_PASSWORD', 'wp_password');

/** MySQL hostname */
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
  define('DB_HOST', ':/cloudsql/YOUR_PROJECT_ID:INSTANCT_ID');
}else{
  define('DB_HOST', '127.0.0.1');
}

Followed these instructions: https://developers.google.com/appengine/articles/wordpress

the google cloud instance run on a separate project but the app is allowed to access

Solutions

The google app engine documentation states

"Google Cloud Platform project called is connecting to a Cloud SQL instance named ."

you are probably getting an error because for project id you are using the project Id for your appengine application not your Cloud SQL project ID. so try:

$db = new pdo('mysql:unix_socket=/cloudsql/<sql-project-id>:<sql-instance-name>;dbname=<db-name>', 'root', '');

If you are migrating your WP to GCE w/Cloud SQL, you should:

  1. Create a cloud storage bucket & upload your mysqldump file (with --hex-blob condition).
  2. Create a cloud SQL instance + create a root password (no password by default).
  3. Import the *.sql (or gzip) file up into the database.
  4. Create a [WordPress] user with privileges to that db access within that cloud sql instance.
  5. Pre-authorize GCE instance access to the Cloud SQL instance, by static IP, or ephemeral IP [CIDR format].
  6. Depending on your [WP] GCE server flavor (e.g. debian), install mysql-client.
  7. Create a Cloud SQL IPv4 address.
  8. Copy the address into your WP config.php file, like: define('DB_HOST', 'xx.xx.xxx.xxx:3306');

Your WP site should establish the database connection on the next page refresh.

Make sure your app engine instance and Cloud SQL instance is set to the same region.

By default, app engine is set to United States.

Lastly, check that you've authorised your app engine app in your Cloud SQL instance.

Similar questions

How to host a wordpress blog from a domain pointed to an app hosted with google app engine?
I have a Python web app hosted with Google App Engine with a .com pointed towards the App Engine app. I would like to start a Wordpress blog at mydomain.com/blog. Since Wordpress runs on PHP, I reckon it would be easier to host the Wordpress blog on my other web host account with cpanel and change some domain pointer. What is the best way to achiev...
Cannot remove a Wordpress cron job from an empty app on Google App Engine
We installed Wordpress on GAE to test the performance and decided to remove it after all. It was linked to a Bitbucket install and an empty version was deployed to remove Wordpress. However, even if the latest build being pushed has zero files (other than index.php & app.yaml), a wp-cron.php file runs every 15min. I also cannot turn off GAE as ...
What are the WordPress analogs\clones that would run under Google App Engine?
So I want it to run on free google app engine version, I want it to be more or less structured like WP (meaning end user experience). I need clean readable source so I could change it as I wish. If there are no such alike WP ones than some other Blog Engine would work for me. What are the WordPress analogs\clones that would run under Google App Eng...
How to Run Wordpress Blog on Google App Engine Locally
Following the Wordpress on GAE tutorial, I have managed to successfully deploy my blog to App Engine. However, I would like to be able to run my blog locally as I continue its development, so that I can inspect error logs, etc. Using the GAE dev server, I try to run it like so: But I run into this problem: I have not changed my app.yaml nor any oth...
A blog engine to integrate with a java app. Which blog engine?
I have to setup a blog engine that "has to be integrated with a java app". These are my requirements, I'm not kidding. The java app is a web app that serves very dynamically changed content. What exactly the blog and this app are going to exchange - I do not know, because my client doesn't know. (yes, I know, my client is ..., but this is the case)...
Google-App-Engine[PHP]: Error trying to establish database connection
I am finding a problem with the cloudsql as database connection is not being established. I have followed the following site step-by-step https://googlecloudplatform.github.io/appengine-php-wordpress-starter-project/ However I seem to be finding problems after deploying the project to the appengine and accessing the wordpress installation page with...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .