Kurt Peek Kurt Peek - 2 months ago 18
MySQL Question

How to add a user to a MySQL instance on the Google Cloud Platform

I'm trying to follow the Quick Start WordPress for Google App Engine guide, but ran into an "Error establishing a database" when trying to run Wordpress locally (see below).

enter image description here

I'm having some trouble with the following instruction:

"After your Cloud SQL instance is created, go to the Access Control section of your instance and click on Users. Click New User and create a user with the name root and specify a password. Now you can connect to your Cloud SQL instance using 3rd-party tools, which we'll do later."

When I go to the Instance details for the instance I created, I don't see any New User button, but only a button to change the root password (see below).

enter image description here

I simply changed the password for the root user. Is this in accordance with the instructions?

Further, how would I modify

wp-config.php
accordingly? I now have the following:

// ** MySQL settings - You can get this info from your web host ** //

if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
/** The name of the Cloud SQL database for WordPress */
define('DB_NAME', 'wordpress_db');
/** Live environment Cloud SQL login and SITE_URL info */
/** Note that from App Engine, the password is not required, so leave it blank here */
define('DB_HOST', ':/cloudsql/wordpress-143922:wordpress');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
} else {
/** The name of the local database for WordPress */
define('DB_NAME', 'wordpress_db');
/** Local environment MySQL login info */
define('DB_HOST', '127.0.0.1');
define('DB_USER', 'root');
define('DB_PASSWORD', 'password');
}


where
'password'
is replaced by the password I used to set up MySQL locally. Since I've specified a password on the App Engine, should I also not fill it into the first
DB_PASSWORD
field?

Answer

Make sure you are editing the wp-config.php file inside the wordpress directory. That demo ships with another (sample) version outside the wordpress directory, which causes confusion.

Also, you need the server location in the DB_HOST section. For example, if in the US-Central district:

    if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
        /** The name of the local database for WordPress */
        define('DB_NAME', 'wordpress_db');
        /** Live environment Cloud SQL login and SITE_URL info */
        /** Note that from App Engine, the password is not required, so leave it blank here */
        define('DB_HOST', ':/cloudsql/wordpress-143922:us-central1:wordpress');
        define('DB_USER', 'root');
        define('DB_PASSWORD', 'password&%^&');
    } else {
        /** The name of the local database for WordPress */
        define('DB_NAME', 'wordpress_db');
        /** Local environment MySQL login info */
        define('DB_HOST', '127.0.0.1');
        define('DB_USER', 'root');
        define('DB_PASSWORD', 'password&%^&');
    }
Comments