Reputation:
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
Upvotes: 5
Views: 1052
Reputation: 21
If you are migrating your WP to GCE w/Cloud SQL, you should:
define('DB_HOST', 'xx.xx.xxx.xxx:3306');
Your WP site should establish the database connection on the next page refresh.
Upvotes: 1
Reputation: 49
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', '');
Upvotes: 0
Reputation: 21
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.
Upvotes: 0