Another simple task that’s often hard for beginners is importing and exporting MySQL dumps. Here is quick rundown on how to do it.
To export data you need to use
Options given to
-u db_user– connect as user
-p– use password, it will ask you to enter your password
db_nameis the name of MySQL database you want to dump
> dump_name.sql– by default
mysqldumpwill print out the dump to terminal, but simple output redirect with
>will instead write it to given filename, in this case
Now that you have
dump_name.sql file with all SQL queries needed to replicate your database you can import it using general-purpose
User, password, and database name options are the same as for
mysql reads input from terminal this time we can use
< to read input from given file instead.
As always for more information you can consult manual using
man mysqldump and