简体   繁体   English

Wordpress Multisite“建立数据库连接时出错”问题

[英]Wordpress Multisite “Error establishing a database connection” issue

I studied lots of questions on Stackoverflow Such as This , and on net , but none solved my issue. 我研究了很多的#2问题像这样 ,和网,但没有解决我的问题。

I have multisite working on domain X working well. 我在域X上的多站点工作正常。 Now I moved it to my server with all DB URL Replace. 现在,我将其所有DB URL Replace移至我的服务器。 Also I changed wp-config and htaccess accordingly. 我也相应地更改了wp-confightaccess

The issue is when I set define('MULTISITE', false); 问题是当我设置define('MULTISITE', false); is false then only base site runs and for other subsites it gives 404 error. 如果为false则仅运行基础站点,对于其他子站点,则显示404错误。

But I have multisite , I just moved to my instance and must have MULTISITE as true for multisite to work. 但我多点,我刚搬到我的实例,并且必须具有MULTISITE作为true的多点工作。

Now when i set it as true , I get 现在,当我将其设置为true时,我得到

Error establishing a database connection 建立数据库连接时出错

error. 错误。 I don't know what is actually going on . 我不知道到底发生了什么。 I debugged but could not get it solved. 我调试了但无法解决。

My config code for multisite 我的多站点配置代码

/* 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);

//My Htaccess ( it does not have any issue) //我的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]

I solved it & it worked :) 我解决了它并起作用了:)

In wp_blogs table , wp_blogs表中,

Old structure was 旧结构

Domain : localhost/smart_facility_linux
Path : /

But i changed it to to make it work as follows: 但我将其更改为使其工作如下:

For root site: 对于根站点:

Domain : localhost
Path : /smart_facility_linux/

For sub site 1 (any subsite under main site ,I just gave example) : 对于子站点1(主站点下的任何子站点,我都给出了示例):

Domain : localhost
Path : /smart_facility_linux/subsite1/

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

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