php - 使用 GAE 部署 Wordpress 时出现问题 - 本地运行正常

标签 php mysql wordpress google-app-engine google-cloud-sql

我正确设置了 Cloud SQL 实例,并且 wordpress 在本地正常运行。 当我尝试运行以下命令时,其中 INSTANCE_IP 是我的 Cloud SQL 实例的 IP 地址,我的语法出现错误:

{PATH_TO_MYSQL_BIN}/mysql --host=INSTANCE_IP --user=root --password
create database wordpress_db;
exit;

编辑,错误信息:

{PATH_TO_MYSQL_BIN}/mysql --host=xxx.19x.2xx.xx --user=root --password       -> create database wordpress_db;                                            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{PATH_TO_MYSQL_BIN}/mysql --host=173.194.243.33 --user=root --password create da' at line 1

如果有人能告诉我我的语法有什么问题那就太好了,在此先感谢。 以下是我认为相关的 wp-config.php:

// Required for batcache use
    define('WP_CACHE', true);

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress_db');

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

    if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
        /** Live environment Cloud SQL login and SITE_URL info */
        define('DB_HOST', ':/cloudsql/your-project-id:wordpress');
        define('DB_USER', 'root');
        define('DB_PASSWORD', '');
    } else {
        /** Local environment MySQL login info */
        define('DB_HOST', '127.0.0.1');
        define('DB_USER', 'root');
        define('DB_PASSWORD', 'password');
    }

    // Determine HTTP or HTTPS, then set WP_SITEURL and WP_HOME
    if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443)
    {
        $protocol_to_use = 'https://';
    } else {
        $protocol_to_use = 'http://';
    }
    define( 'WP_SITEURL', $protocol_to_use . $_SERVER['HTTP_HOST']);
    define( 'WP_HOME', $protocol_to_use . $_SERVER['HTTP_HOST']);

    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');

    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

最佳答案

看起来您正在遵循来自 Google 云项目网站的指南。

这里有一些解决方案:

  • 首先,如果您在安装 mysql 期间更改了用户名或密码,请确保在 wordpress 的 config.php 中进行更新。
  • 事情是这样的 - 在 MySQL 中,如果您正在使用 Workbench,那么您需要运行的是:

    创建数据库wordpress_db;

我相信如果您从 cmd 工具运行另一个脚本的话。

关于php - 使用 GAE 部署 Wordpress 时出现问题 - 本地运行正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24858474/

相关文章:

php - 强制 WordPress 页面刷新

php - 获取.dat文件内容php

php - 简单的 PHP 查询在一个页面上有效,在另一个页面上崩溃

mysql - 使用 SQL,如何编写一个查询,如果没有条目则返回 null,但如果存在则列出所有条目?

php - 我无法将数据添加到 SQL 记录

wordpress - 我在Elementor Page构建器中遇到了问题

php - SUM 与 MYSQL 中的 JOIN 表给出错误的结果

php - 不使用 WordPress 中的 dbDelta() 创建触发器

mysql - NSURLSession 密码安全

mysql - WordPress 旋转推文插件导致数据库崩溃