1. Home
  2. Cloud & Dedicated Servers
  3. MySQL
  4. How to backup mysql databases from the command line on windows

How to backup mysql databases from the command line on windows

MySQL is an extremely popular database engine on windows today and a common question our team fields is "How do you backup mysql databases on windows?" 
 
The easiest way to backup a database on windows is using the mysqldump command. you’ll execute the command as follows:
 
mysqldump database-name > database-script.sql -u USERNAME -p
 
In that command you’re executing the mysqldump command. This is generally found in the bin folder of your mysql server installation. Dissecting the command we have the following:
  1. mysqldump – this is the executable we’re calling to do the database backup, this is included in all installs of mysql by default so you don’t have to download anything new.
  2. database-name – this is the name of your database you’re trying to backup.
  3. the ">" – This tells mysqldump that all of your output should be redirected to a file that follows.
  4. database-script.sql – this is the name of the file that your output will be stored in.
  5. -u – this is a command line argument that says the username follows this flag
  6. USERNAME – This is the mysql database username that has access to the database you’re backing up.
  7. -p – this is a command line argument that tells mysqldump to prompt you for the password for the user you defined earlier.
Once you execute that command you’ll be prompted for the password, simply copy and paste the password or type the password and hit enter.  Wait a few minutes as the command executes and shortly you’ll have a new file in your folder named database-script.sql (or whatever you named your output file) and that is the script you’d execute to restore the database backup (or database dump as it’s commonly referred to).
 

Content retrieved from: https://support.appliedi.net/kb/a1330/how-to-backup-mysql-databases-from-the-command-line-on-windows.aspx.

Updated on November 11, 2019

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT