【问题标题】:Wordpress Multisite “Error establishing a database connection” issueWordpress 多站点“建立数据库连接时出错”问题
【发布时间】:2015-04-16 13:29:00
【问题描述】:

我在 Stackoverflow Such as This 和网上研究了很多问题,但没有一个能解决我的问题。

我在域 X 上运行的多站点运行良好。现在我用所有的 DB URL Replace 将它移到了我的服务器上。我也相应地更改了wp-confightaccess

问题是当我将define('MULTISITE', false); 设置为false 时,只有基本站点运行,而对于其他子站点,它会给出404 错误。

但我有 multisite ,我刚刚移动到我的实例,并且必须将 MULTISITE 设置为 true 才能使 multisite 工作。

现在,当我将其设置为 true 时,我得到了

建立数据库连接时出错

错误。我不知道实际发生了什么。我调试过,但无法解决。

我的多站点配置代码

/* Multisite */
define('WP_ALLOW_REPAIR', true);
define('MULTISITE', true);
define('WP_ALLOW_MULTISITE', true);
//define('RELOCATE',true);


define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
$base = '/';
define('PATH_CURRENT_SITE', '/smart_facility_linux/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

//我的Htaccess(没有问题)

RewriteEngine On
RewriteBase /smart_facility_linux/
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
#RewriteRule ^privacy-statement.html /privacy-statement [L]

【问题讨论】:

  • 请添加完整的错误信息...
  • 它只是在我的回答中给出了get Error建立数据库连接在我的答案中以粗体检查。

标签: php wordpress .htaccess


【解决方案1】:

我解决了它并且它有效:)

wp_blogs 表中,

旧结构

Domain : localhost/smart_facility_linux
Path : /

但我将其更改为使其工作如下:

对于根站点:

Domain : localhost
Path : /smart_facility_linux/

对于子站点1(主站点下的任何子站点,我只是举例):

Domain : localhost
Path : /smart_facility_linux/subsite1/

【讨论】:

    猜你喜欢
    • 2021-04-19
    • 2013-05-02
    • 2015-12-24
    • 2019-02-10
    • 2021-05-28
    • 1970-01-01
    • 2015-08-11
    • 2012-12-29
    • 1970-01-01
    相关资源
    最近更新 更多