Restoring MySQL Database More

There's a few ways to restore a MySQL database. If you have the SQL dump file, it's relatively easy you can simply import it.

If you have a copy of the data directory (/var/lib/mysql) you can use the following technique.

In this example the data directory I want to get the database from is located at /tmp/mysql160407

mysqld_safe --skip-grant-tables --port=3307 --socket=/var/lib/mysql/mysql2.sock --pid-file=/var/run/mysqld/mysqld2.pid --datadir=/tmp/mysql160407 & mysqldump --protocol=TCP --port=3307 --all-databases > /tmp/mysql160407.sql

You will now have an SQL dump file located at /tmp/mysql160407.sql