MySQL export and import database from command line

This is how to export and import a MySQL database from the command line

Export
mysqldump -u root -p mydatabase | gzip -9 > /home/myuser/mydatabase.sql.gz

press enter and you will be asked for root password

Import
gunzip < /home/myuser/mydatabase.sql.gz | mysql -u root -p mydatabase

press enter and the database will be imported to mydatabase database.

On Windows: This is how to import a MySQL database from the command line.
Save the file in the root of C: and/or make sure the entire path/filename has no spaces or none A-Z characters.

From start menu, type "cmd" and press Enter
on the command line, type:

mysql -u root -p

and press Enter
type the password and press Enter
then type:

SOURCE C:/mysql_file.sql;
and press Enter
Knowledge keywords: