dongquepao8653 2014-01-18 09:27
浏览 122
已采纳

本地Wordpress站点无法访问本地数据库(不是错误建立连接)

I'm having an issue with a WordPress site that I'm running locally on my machine accessing my local database that I've created. The database I pulled down is from a live, working database, but I would like to work locally for both the db and WP site.

When I browse to the site, I'm not getting an "Error establishing connection" message, so my wp-config is setup correctly with the hostname, username, and pw. I can see the browser trying to load the page, but after a while (1-2 mins), the browser stops, but no error message is returned.

I then purposely put in wrong credentials in my wp-config, where I then the typical "Error establishing..." message.

I'm not sure how to solve this issue because I'm not even sure what the problem is. Could anyone please provide some insight into what I should look into?

Edit

PHP error logs contain the following

[UTC] PHP Warning: mysql_connect(): MySQL server has gone away in C:\xampp\htdocs\.........\web\content\wp-includes\wp-db.php on line 1147 
[UTC] PHP Warning: mysql_connect(): Error while reading greeting packet. PID=3632 in C:\xampp\htdocs\...\web\content\wp-includes\wp-db.php on line 1147 
[UTC] PHP Warning: mysql_connect(): MySQL server has gone away in C:\xampp\htdocs\..\web\content\wp-includes\wp-db.php on line 1147 
[UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\..\web\content\wp-includes\wp-db.php on line 1147
  • 写回答

3条回答 默认 最新

  • douhuitan5863 2014-01-18 09:55
    关注

    Try overriding these settings in wp_config.php with the url of your local site

    define('WP_HOME','url_to_your_site');
    define('WP_SITEURL','url_to_your_site');
    

    More info here: http://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php

    Those two values are stored in the db, and WP will freak out if you don't set them.


    Edit:

    Based on your logs, this is just MySQL and php not talking.

    Make sure that MySQL is running and look at the wp_config settings for the db connection.

    Make sure you are connecting to the right port, and try connecting to 127.0.0.1 instead of localhost.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部