How to import/export database using MySql command line
Sometimes when you have large databases, phpmyadmin or similar tool might fall when it comes to exporting or importing. The easiest (and fastest) way is to use command line.
To export use this command:
mysqldump -u USER -p PASSWORD DATABASE > filename.sql
To import database from dump file (in this case called filename.sql) use:
mysql -u username -p password database_name < filename.sql
If you are on Windows you will need to open CMD and go to directory where mysql.exe is installed. If you are using WAMP server then this is usually located in:
C:\wamp\bin\mysql\mysql5.1.36\bin (*note the version of mysql might be different)
So you will:
cd C:\wamp\bin\mysql\mysql5.1.36\bin
and then execute one of the above commands.
Disqus