Importing and exporting MySQL databases using the command line in Linux is extremely easy. It is often much more practical to use the command line instead of a tool such as phpMyAdmin, especially when managing a large number of websites. An existing database and database user is required before importing a database (unless your SQL includes a create database statement). Instructions for creating a database can be found in my post about creating a database using the command line.
- Access to your server via SSH
- An existing database (to export) or a database dump file to import
In the examples below, replace USER with your database username and DATABASE with your database name.
mysqldump -u USER -p DATABASE > backup.sql
mysql -u USER -p DATABASE < backup.sql