Tips – Command Line to Restore MySQL Database

This method apply to XAMPP and phpMyAdmin.

1. Backup database from the source. Normally the database will using name : localhost.sql
2. After backup, transfer to any folder in the MySQL server that you want to restore, it’s better put into /root
3. Delete database using phpMyadmin if the database exist
3. Then execute commmand: mysql -u root -p < localhost.sql
4. If using XAMPP, it may show error message: -bash: -bash:: command not found
5. If you found this error, try find using this command: find /opt/lampp -name mysql
6. You should found this result: /opt/lampp/bin/mysql
7. Now create shortcut to execution path (/bin)
8. Using this command to create shortcut: ln -s /opt/lampp/bin/mysql /bin/mysql
9. After that, try again to execute: mysql -u root -p < localhost.sql
10. If everything OK, you should prompted the phpMyadmin password
11. Enter password and it will restore the database
12. Double check again the restored database

Good Luck!