简体   繁体   English

如何在Google Cloud Platform上将用户添加到MySQL实例

[英]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). 我正在尝试遵循Google App Engine的WordPress快速入门指南,但是尝试在本地运行Wordpress时遇到“建立数据库错误”的问题(请参见下文)。

在此处输入图片说明

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." “创建Cloud SQL实例后,转到实例的访问控制部分,然后单击“ 用户” 。单击“ 新用户”并创建一个名为root的用户并指定密码。现在,您可以使用第3个连接到Cloud SQL实例方工具,我们将在以后进行。”

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). 当我转到所创建实例的“ 实例详细信息 ”时,看不到任何“ 新用户”按钮,只有一个用于更改根密码的按钮(请参见下文)。

在此处输入图片说明

I simply changed the password for the root user. 我只是更改了root用户的密码。 Is this in accordance with the instructions? 这符合指示吗?

Further, how would I modify wp-config.php accordingly? 此外,我将如何相应地修改wp-config.php 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. 其中'password'被我用来在本地设置MySQL的密码代替。 Since I've specified a password on the App Engine, should I also not fill it into the first DB_PASSWORD field? 由于我已经在App Engine上指定了密码,因此是否也不DB_PASSWORD其填写到第一个DB_PASSWORD字段中?

Make sure you are editing the wp-config.php file inside the wordpress directory. 确保您正在编辑wordpress目录中的wp-config.php文件。 That demo ships with another (sample) version outside the wordpress directory, which causes confusion. 该演示版在wordpress目录外附带了另一个(示例)版本,这引起了混乱。

Also, you need the server location in the DB_HOST section. 另外,您需要在DB_HOST部分中找到服务器位置。 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&%^&');
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在谷歌云平台上搭建论坛网站? - How to setup a forum website on Google Cloud Platform? 如何将php zip添加到服务器,我在谷歌云平台上使用wordpress - How to add php zip to server, I'm using wordpress on google cloud platform 无法在Google Cloud Platform中添加app.yaml - Unable to add app.yaml in google cloud platform 如何在google cloud sql实例上创建数据库 - How to create database on google cloud sql instance 在 Google Cloud Compute Engine 虚拟机实例上设置 MySQL - Setting up MySQL on a Google Cloud Compute Engine VM instance Google Cloud Platform文件位置 - Google Cloud Platform files location 如何在PHP和Google Cloud Platform上部署PHP应用程序? - How can I deploy my PHP application on Google cloud Platform? Google云端平台:如何使用GCP资源在本地环境中进行开发 - Google Cloud Platform : How to develop on my local environment with GCP resources 如何在Google Cloud Platform上使用Firestore正确部署PHP应用程序? - How to properly deploy PHP app with Firestore on Google Cloud Platform? 如何在Google Cloud Platform上的App Engine中更改php版本(运行时)? - How to change php version (runtime) in App Engine on Google Cloud Platform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM