MySQL: Import and export database using terminal

2012-06-25 Databases

Thanks to terminal (Ubuntu) you're able to import and export your database in a very easy way. Open terminal (CTRL + ALT + T) and then depending on action use this code.

To import database from local *.sql file:

mysql -u user_name -p database_name < dump.sql

To export database to local *.sql file:

mysqldump -u user_name -p database_name > dump.sql

After that you'll be prompted to enter password for MySQL database you've chosen. This short tip just shows a basic usage of mysql and mysqldump command. More informations you'll find out elsewhere.

Do NOT follow this link or you will be banned from the site!