简体   繁体   English

建立与Cloud SQL的数据库连接时出错

[英]Error establishing a database connection to Cloud SQL

please forgive a novice question: 请原谅一个新问题:

I have Wordpress up and running on my development server with no problems. 我已经安装了Wordpress并在我的开发服务器上正常运行。 When I try to upload it using appengine, I get the following error output from WP_DEBUG, where MYSITEID is the name of my site: 当我尝试使用appengine上载它时,我从WP_DEBUG收到以下错误输出,其中MYSITEID是我的网站的名称:

Warning: mysqli_connect(): (HY000/2002): Unable to find the socket transport "tcp" -
did you forget to enable it when you configured PHP? in 
/base/data/home/apps/s~MYSITEID/wp.370505361471441320/wordpress/wp-content/db.php on line 176

It goes on: 它继续:

"This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at :/cloudsql/MYSITEID:wordpress . This could mean your host's database server is down." “这意味着wp-config.php文件中的用户名和密码信息不正确,或者我们无法通过:/cloudsql/MYSITEID:wordpress与数据库服务器联系。这可能意味着您主机的数据库服务器已关闭。”

My Cloud SQL instance is up and running and I followed the tutorial steps 7 and 8 exactly. 我的Cloud SQL实例已启动并正在运行,我完全按照了教程步骤7和8进行操作。

My wp_config db_host section reads: 我的wp_config db_host部分读取:

/** MySQL hostname */
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
  define('DB_HOST', ':/cloudsql/MYSITEID:wordpress');
}else{
  define('DB_HOST', 'localhost');
}

From the looks of it my error text is almost verbatim what a phpmyadmin user encountered, but I'm still not sure how to resolve it. 从它的外观来看,我的错误文本几乎完全是phpmyadmin用户遇到的,但是我仍然不确定如何解决它。 Do I need to change something on the DB_HOST line? 我需要在DB_HOST行上进行更改吗? See phpMyAdmin on GAE - Authentication 请参阅GAE上的phpMyAdmin-身份验证

Thanks for any help - really appreciate that GAE for PHP exists! 感谢您的帮助-非常感谢GAE for PHP的存在!

Turns out the issue was in db.php - which I had installed in wp-content per the instructions here: http://wordpress.org/plugins/mysqli/installation/ 原来问题出在db.php中-我已经按照此处的说明将其安装在wp-content中: http : //wordpress.org/plugins/mysqli/installation/

I'm not sure why I originally installed mysqli instead of using mysql; 我不确定为什么我最初安装mysqli而不是使用mysql。 it seemed to fix an earlier php error I was having on my development server. 它似乎解决了我在开发服务器上出现的早期php错误。 But after removing db.php both my dev version and the Cloud SQL instance work just fine! 但是在删除db.php之后,我的开发版本和Cloud SQL实例都可以正常工作!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM