Export / Backup MySQL database:
Utility named mysqldump can be used to dump a database or a collection of databases for backup or for transferring the data to another MySQL server. The dump file is a text file which contains SQL statements to create the table and/or populate the table.
How to export / Backup a Mysql database to a .sql file
# mysqldump -u USERNAME -p DATABASENAME > FILENAME.sql
USERNAME is the MySQL admin user
DATABASENAME is the name of the database that need to be exported /Backup
FILENAME.sql is the name of the file where your data will be exported
Now It will ask for password,Enter MySQL admin password.
You can dump all databases by doing:
# mysqldump -u root -p --all-databases > all_my_data.sql
Now We can See How to Import/Restore MySQL database:
Below is the simple command through which you can restore / import the already exported MySQL database file (.sql)# mysql -u USERNAME -p DATABASENAME < FILENAME.sql
You will be prompted for the MySQL administrator password.