Restore MySQL database from files

If you have MySQL database files and you want to restore database on new server do next steps:

1. Stop MySQL server:

systemctl stop mysql

2. Copy all files of database to /var/lib/mysql directory;

3. Also copy files:

/var/lib/mysql/ibdata1
/var/lib/mysql/ib_logfile0
/var/lib/mysql/ib_logfile1

4. Change user and group of all files in directory /var/lib/mysql to mysql:mysql:

chown -R mysql:mysql .

5. Change permission of files in directory /var/lib/mysql to 660

find . -type f -print0 | xargs -0 chmod 660

6. Start MySQL server:

systemctl start mysql

To restore database from SQL dump use command:

mysql -u [user] -p [database_name] < [filename].sql