Select Page

If you’re a developer who likes to use the Windows platform when building software, you’ll no doubt be using MySQL at some point along the way and an IDE such as Eclipse, NetBeans or something else. For the more basic activities you’ll be doing within your application when interacting with your MySQL database, there will be nothing much to worry about. Whereas with other work you’ll be doing, it is essential to take a backup of your MySQL database with ease, to make sure that you don’t lose all of your test data in the database when you make a mistake in one of your SQL commands.

When you installed MySQL in the first place, you’ll likely have installed this somewhere such as;

 

C:\Program Files\MySQL\MySQL Server x.x

 

So open command prompt and navigate to the folder that your MySQL version is installed in, then inside the bin folder;

 

CD C:\Program Files\MySQL\MySQL Server x.x\bin

 

Next you need to run the following command. Make sure you personalise the details according to the database you created in the first instance;

 

Mysqldump –u yourusername –p databasename > C:\Users\YourUsername\databasebackup.sql

 

Note, if you try to save the file to C:\ for example, then this will result in an access denied error message. The reason for this is because you need Administrator privileges to do this, just like when you’re installing a new piece of software. So instead, make sure you save the file within your current user account that you are logged into Windows with.

Then if you ever need to restore the database, run the following command;

 

mysql -u yourusername -p databasename < C:\Users\YourUsername\databasebackup.sql

 

Simples. Yet often can be a little more challenging in practice depending on the details you have configured. Hope this is a useful starting point for when you need to do this.

The following two tabs change content below.

Michael Cropper

Founder & Managing Director at Contrado Digital Ltd
Michael founded Contrado Digital in 2013. He has experience working with national and multi-national brands in a wide range of industries, helping them achieve awesome results. Michael regularly speaks at local universities and industry events while keeping up with the latest trends in the digital industry.