Scenario

We assume that your VPS cannot be started and you are trying to recover MySQL databases from VPS Recovery Mode or VPS backup files.

Steps

1. Install MySQL Server. The same version of MySQL should be used although it is possible to restore to a newer version.

yum install mysql-server

2. Stop MySQL Server. This is required in order to add to the data folders.

service mysql stop

3. Copy old MySQL data to new MySQL server data files location.

cp -rf /mnt/var/lib/mysql/* /var/lib/mysql

4. Change files ownership. Ensure that files are owned by mysql user.

chown -R mysql:mysql /var/lib/mysql

5. Start your MySQL server.

service mysql start

6. Check & Repair all database tables. Depending on the version of MySQL you are running you should run MYSQLCHECK. This step is necessary in order to ensure that the data is not corrupted.

mysqlcheck -rA

7. Export databases.

mysqldump --all-databases > all_databases.sql
Did this answer your question?