To restore database mysql (specially INNODB database) from folder is quietly easy. Follow this steps from SSH with root privilege:

1) Setup mysql with small vserver from Digital Ocean (or vultr, linode, etc) with Ubuntu 16.04:

apt-get update

apt-get upgrade

apt-get install mysql-server

2) Create database with the same name, same user, and same password:

mysql -u root -p

Insert root password.

  • To create database name: CREATE DATABASE name_of_database;

  • To create user database and password: GRANT ALL ON name_of_database.* TO 'user_database'@'localhost' IDENTIFIED BY 'PASSWORD';

3) Now stop mysql engine : service mysql stop

4) Copy database files from folder with cp, scp, or rsync command from vserver:

rsync -avzhe 'ssh -p 22' [email protected]:/var/lib/mysql/name_of_database/ /var/lib/mysql/name_of_database

(Note: change the IP Address with your source server IP Address)

5) Copy also the ib* files to /var/lib/mysql:

rsync -avzhe 'ssh -p 22' [email protected]:/var/lib/mysql/ib* /var/lib/mysql

6) Dont forget to chown all files to mysql:mysql

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

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

Without this step, restoring database will not work.

7) Add this code to /etc/mysql/my.cnf under [mysqld]


innodb_force_recovery = 4

8) Now install Phpmyadmin:

apt-get install phpmyadmin

Select "YES" when dialog prompted and insert Password for Phpmyadmin.

9) Start Mysql:

service mysql start

10) Go to phpmyadmin URL from browser:

11) Insert database username and password, and you will see all database read correctly with all tables. Dont be confuse if file size is different. It will be corrected with mysqldump command below.

12) Final step, mysqldump database:

mysqldump -u user_database -p name_of_database > /var/lib/mysql/name_of_database.sql

13) Finish, now you have a complete database backup with .sql format.