Plesk

Cannot start MariaDB on Plesk server: the directory /var/lib/mysql is not empty, so initialization cannot be done

Symptoms

Cause

MariaDB set up is corrupted.

Resolution

  1. Connect to the server via SSH

  2. Stop MariaDB:

    # systemctl stop mariadb

  3. Move all content out of /var/lib/mysql directory:

    # mkdir /var/lib/mysql_bk && mv /var/lib/mysql/* /var/lib/mysql_bk

  4. Start and then stop MariaDB:

    # systemctl start mariadb
    # systemctl stop mariadb

  5. Copy contents from backed-up directory to /var/lib/mysql:

    # cp -a /var/lib/mysql_bk/* /var/lib/mysql

  6. Open the my.cnf file with a text editor:
    1. on CentOS/RHEL-based distributions

      # vi /etc/my.cnf

    2. on Debian/Ubuntu-based distributions

      # vi /etc/mysql/my.cnf

  7. Add the skip-grant-tables directive under the [mysqld] section:

    [mysqld]
    skip-grant-tables
    bind-address = ::

  8. Restart MariaDB and restore the mysql database from daily dump:

    # zcat /var/lib/psa/dumps/mysql.daily.dump.0.gz | sed -n '/-- Current Database: mysql/,/-- Current Database:*/p' | plesk db

  9. Restore the admin user by following the instructions from the article "Unable to access Plesk UI or its database on Linux: Access denied for user 'admin'@'localhost' (using password: YES)";
  10. Remove the skip-grant-tables directive under the [mysqld] section of the my.cnf file.
  11. Restart MariaDB:

    # systemctl restart mysql && systemctl restart mariadb

Exit mobile version