Articles in this section

Plesk Backup finish with database warnings: Unable to back up database db_name. Error: SQLSTATE[HY000] [2002] Connection refused

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

  • A site backup completes with the following warnings regarding several databases:

    CONFIG_TEXT: Backup Task Mar 19, 2022 02:44 AM Details
    Warning: Database "wp_database1"
    Unable to make database dump. Error: Failed to exec mysqldump: Exit code: 2: mysqldump: Got error: 2013: "Lost connection to MySQL server during query" when using LOCK TABLES
    Warning: Database "wp_database1"
    Unable to back up database wp_database1. Error: DB query failed:
    "SET sql_mode = ''"

    CONFIG_TEXT: Error: SQLSTATE[HY000] [2002] Connection refused
    Warning: Database "wp_database2"
    Unable to back up database wp_database3. Error: SQLSTATE[HY000] [2002] Connection refused
    Warning: Database "wp_database3"
    Unable to back up database wp_database3. Error: SQLSTATE[HY000] [2002] Connection refused

  • The following logs regarding the same databases can be found at /var/log/plesk/panel.log:

    Failed to process database 'wp_database1' from domain 'example.com': MySQL error 2006: MySQL server has gone away executing query:
    SHOW TABLE STATUS FROM `wp_database1`
    Failed to process database 'wp_database2' from domain 'example.com': MySQL error 2006: MySQL server has gone away executing query:
    SHOW TABLE STATUS FROM `wp_database2`
    Failed to process database 'wp_database3' from domain 'example.com': MySQL error 2006: MySQL server has gone away executing query: 
    SHOW TABLE STATUS FROM `wp_database3`
    Failed to process database 'wp_database4' from domain 'example.com': MySQL error 2006: MySQL server has gone away executing query: 
    SHOW TABLE STATUS FROM `wp_database4`
    
  • The solution described on this article does not solve the issue.

  • When the MySQL log is checked while reproducing the issue, the following errors regarding other Databases are found:

    [ERROR] mysqld: Table './database5/table_name1' is marked as crashed and should be repaired
    [Warning] Checking table:   './database5/table_name1'
    [ERROR] mysqld: Table './other-database/table_name2' is marked as crashed and should be repaired
    [Warning] Checking table:   './database5/table_name2'
    

Cause

One or more crashed database table causes to MySQL service to go down for a short period of time enought to results in the backup errors such as "Lost connection to MySQL server during query" or "Connection refused" or "MySQL server has gone away".

Resolution

Apply one of the following solutions:

A: Restore the affected databases from a working backup by following the instructions on how to restore a user's database from a Plesk backup.

B: Repair the affected databases by following the instructions on How to fix InnoDB corruption cases for the MySQL databases on Plesk for Linux?

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.