Backing up your MySQL database or generating a copy of it to shift around is quite a simple affair thanks to the powerful mysqldump command that ships with MySQL.
To generate a backup sqldump, simply execute:
mysqldump -h localhost -u [MySQL user, e.g. root] -p[database password] -c --add-drop-table --add-locks --all --quick --lock-tables [name of the database] > sqldump.sql
Note the lack of a space between -p and the password! Obviously if you don’t have a password assigned, simply omit the -p switch.
And that is it, all done! :)
Note, restoring a database from a mysqldump is as simple as: mysql -u [MySQL user, e.g. root] -p[database password] < sqldump.sql
You might also enjoy:
-
The quickest way to import a properly generated SQL dump containing structure and table definitions plus data into a MySQL database is to simply pipe the fi ...
-
One of the easiest ways to backup and restore your MySQL database (or even just to move databases between different servers) is to make use of MySQL's handy ...
-
To delete a database from a MySQL server instance, we need to make a DROP DATABASE call against the server. First, fire up MySQL in your terminal and lo ...
-
To create a user account from a MySQL server instance, we need to make use of a CREATE USER call to the mysql.user table. First, fire up MySQL in your t ...
-
One of the most important things you need to do when setting up your new MySQL server instance is to set the password for the root user account. By default, ...