【发布时间】:2014-09-11 13:37:05
【问题描述】:
我正确设置了 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', '');
【问题讨论】:
-
您需要至少包含错误消息才能获得正确的答案。
-
已包含,感谢您的评论。
-
你是同时运行
create database命令和登录还是先登录再输入密码后创建? -
我真的去: {PATH_TO_MYSQL_BIN}/mysql --host=xxx.19x.2xx.xx --user=root --password
创建数据库 wordpress_db; -
您是否尝试对数据库名称使用反引号?至少对于数据库名称中的破折号,这通常可以解决问题。
标签: php mysql wordpress google-app-engine google-cloud-sql