With mysqldump, you can dump a database or collection of databases into one or more files containing all the instructions necessary to re-create all your tables and repopulate them with your data. This command can also generate files in CSV (comma-separated values) and other delimited text formats, or even in XML format. Its main drawback is that you must make sure that no one writes to a table while you’re backing it up. There are various ways to do this, but the easiest is to shut down the MySQL server before running mysqldump and start up the server again after mysql dump finishes. Alternatively, you can lock the tables you are backing up before running mysqldump. To lock tables for reading (as we want to read the data), from the MySQL command line issue this command:
LOCK TABLES tablename1 READ, tablename2 READ …
Then, to release the lock(s), enter the following:
UNLOCK TABLES;
By default, the output from mysqldump is simply printed out, but you can capture it in a file through the > redirect symbol.
Use next command in terminal, do not use in mysql client.
The basic format of the mysqldump command is shown here:
mysqldump -u user -p password databasename
However, before you can dump the contents of a database, you must make sure that mysqldump is in your path, or else specify its location as part of your command.
Dumping the publications database to screen:
mysqldump -u user -p etunimitietokantadb publications
Make sure that you replace user and password with the correct details for your installation of MySQL. If there is no password set for the user, you can omit that part of the command, but the -u user part is mandatory unless you have root access without a password and are executing as root (not recommended).