Click Technology

Linux, Windows, Mac it's all good

Backup and restore MySQL database quickly

September8

Very simple. Use the following commands..

Backup to an external file.

On the *nix command line, just run..

mysqldump -u root -p database_name > /path/to/database_dump_file.sql

Punch in the password for root (in this case) and the backup is output to the file database_dump_file.sql. It’s ASCII so it can be edited if needed.

Restore from an external file..

mysql -u root -p database_name < /path/to/database_dump_file.sql

Typed the password and that's it, finished.

Need the database names quickly?

Log in to the database as ususal with the command at the *nix command line.

mysql -u root -p

And then issue the following at the prompt..

mysql> show databases;

and you get this....

+----------------------+
| Database             |
+----------------------+
| information_schema   |
| largedump            |
| dspam                |
| mysql                |
| performance_schema   |
| testdata             |
| testdata_1           |
| dataset_4            |
| dataset_2            |
+----------------------+
9 rows in set (0.01 sec)
posted under Linux Tips

Email will not be published

Website example

Your Comment:

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.