Import MySql database records into an .sql file from the terminal using the MySql command mysqldump, it is a quick and easy way to backup MySql database records.
Requirements:
- MySQL
- Command line terminal
How to manually backup a MySQL database.
mysqldump -uNAME -pPASSWORD DATABASE > database.sqlWhere.
- NAME = the user name who has access to the database.
- PASSWORD = the password of the user name.
- DATABASE = the name of the database to backup.
- database.sql = the sql file where the records will be saved.
Other Examples.
Do not include the password on the command, and enter only when prompted.
mysqldump -uNAME -p DATABASE > database.sqlImport specific TABLE.
mysqldump -uNAME -pPASSWORD DATABASE TABLE > database.sqlImport multiple TABLEs.
mysqldump -uNAME -pPASSWORD DATABASE TABLE1 TABLE2 TABLE3 > database.sqlSpecifically save to linux home directory.
mysqldump -uNAME -pPASSWORD DATABASE > /home/database.sqlSpecifically save to windows drive D.
mysqldump -uNAME -pPASSWORD DATABASE > D:\database.sqlNotes:
- If the path where the file is to be saved was not specified, the .sql file (database.sql) will be saved on the same location where the command is executed.
- The same command can also be executed on windows command line.


Leave a Reply