dongquepao8653 2014-01-18 17: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 17: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条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?