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 
  1. 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';

  1. Now stop mysql engine :

    service mysql stop

  2. 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)

  1. Copy also the ib* files to /var/lib/mysql:
rsync -avzhe 'ssh -p 22' [email protected]:/var/lib/mysql/ib* /var/lib/mysql 
  1. 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.

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

innodb_force_recovery = 4
  1. Now install Phpmyadmin:
apt-get install phpmyadmin

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

  1. Start Mysql:
service mysql start
  1. Go to phpmyadmin URL from browser:

  1. 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.

  2. Final step, mysqldump database:

mysqldump -u user_database -p name_of_database > /var/lib/mysql/name_of_database.sql
  1. Finish, now you have a complete database backup with .sql format.