0
votes

I have enabled Wordpress Multisite and created a new website using it.

Main site: lafznama.com

New site: lafznama.com/books

When I go to new site, it shows error: "Error establishing a database connection".

Q: How to resolve it?

Q: Should I create "books" folder in directory and add a clone copy of Wordpress and also clone MySQL database too?

Here is the wp-config settings which enabled multisite Wordpress:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'lafznama.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Also, here are the settings for .htaccess provided by multisite Wordpress, I applied:

RewriteEngine On
RewriteBase /
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]

The issue is also highlighted here:

enter image description here

1

1 Answers

0
votes

in wp-config.php

define('WP_ALLOW_REPAIR', true);

before “That’s all, stop editing! Happy blogging.”

or test in new php file

<?php 
$link = mysqli_connect('localhost', 'user', 'password'); 

echo 'Connected successfully'; 
mysqli_close($link); 
?>

or recheck in wp-config

define('DB_NAME', 'db name'); 
define('DB_USER', 'db user'); 
define('DB_HOST', 'db localhost etc');