Plesk

Unable to restore the Plesk psa database: ERROR 1813 (HY000) at line 104: Tablespace for table ‘`psa`.`tablename`’ exists. Please DISCARD the tablespace before IMPORT

Symptoms

Cause

The psa database is corrupted.

Resolution

  1. Connect to the Plesk server via SSH.

  2. Create a backup of the files stored in /var/lib/mysql/psa:

    # mkdir /root/varlibmysqlpsa/

    # cp -a /var/lib/mysql/psa/* /root/varlibmysqlpsa

  3. Remove the files:

    # rm -rf /var/lib/mysql/psa/*

  4. Remove the psa database:

    # plesk db "DROP DATABASE psa"

  5. Connect to MySQL and create an empty psa database:

    # MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -uadmin

    MariaDB [(none)]> create database psa;

    Query OK, 1 row affected (0.002 sec)

    MariaDB [(none)]> quit

  6. Restore the psa database from the latest daily backup:

    # cd /var/lib/psa/dumps

    # zcat mysql.daily.dump.0.gz | sed -n '/-- Current Database: `psa`/,/-- Current Database:*/p' | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin --default-character-set=utf8

Exit mobile version