Synology: Error establishing a database connection After WordPress Import

Synology Error establishing a database connection After WordPress Import

You have imported your website from a private hosting directly to your synology nas and then every time you try to access your website you get this error: “Error establishing a database connection”.

synology error establishing a database connection solved

If the password and username match perfectly in the file wp-config.php and all the file permissions are “correct”, the only remaining cause is a wrong configuration of the folders inside the main WEB folder. If before importing your site from a private hosting to your synology you already had a “WEB” folder with the folder called “WordPress” and “phpMyadmin” inside, you just have to insert the folder “yourwebsitename” directly into the  main wordpress folder which was previously created automatically with the first installation of the official synology package. Only in this way will it be recognized by wordpress and the “Error establishing a database connection” error will disappear.

Another possible error is the .htaccess file and the wp-config file (username and password do not match). First of all:
Edit the .htaccess file like this:

# Synology PHP
AddHandler default-handler .htm .html .shtml
AddHandler php-fastcgi .php
AddType text/html .php
Action php-fastcgi /php56-fpm-handler.fcgi
# Synology PHP

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

After you do that, save it and overwrite the old .htaccess file (remember: always make a backup of .htaccess file before you edit or overwrite it).
Another solution is to open and edit wp.config.php then go to DB_HOST and instead ‘localhost’ set ‘localhost:/run/mysqld/mysqld10.sock’ follow the instructions below.

/** MySQL hostname */
define('DB_HOST', 'localhost');
/** MySQL hostname */
define('DB_HOST', 'localhost:/run/mysqld/mysqld10.sock');

If the problem persists, do not hesitate to contact me by email.

Last Updated on by Marius Bogdan Lixandru

Do NOT follow this link or you will be banned from the site!