MySQL backup-how to backup a MySQL database

Source: Internet
Author: User
Tags drupal mysql backup mysql command line

MySQL backup faq:how do I backup a MySQL database?

I can ' t speak about backing up MySQL databases that is modified twenty-four hours a day seven days a week MySQL databases I currently work with, there is always times if I can guarantee that there won ' t is any SQL inserts, D Eletes, or UPDATEs occurring, so I find it's really easy-to-perform a MySQL backup using the Mysqldump utility program. Here's how it works.

Create a MySQL backup with mysqldump

I was just working in a Drupal database, and decided that I wanted to make a backup of Drupal ' s MySQL database before I di D something that might screw up the database (converting a wordpressdatabase to a Drupal database). So, I made a backup of my current MySQL Drupal database using the following mysqldump command:

Mysqldump--opt--user=root--password drupaldb > Drupaldb-20090505.sql

  

Note that this command, is the drupaldb name of the My database, not the password. --passwordThe argument just tells MySQL to prompt me for the password, because I don ' t want to type it right here on the Comman D line. So, immediately after I enter that command, MySQL prompts me for root the user's password, like this:

Enter Password: _

  

Once I Enter that password, my drupaldb database is dumped to a file in the current directory named drupaldb-20090505.sql .

MySQL backup-a slightly different syntax

Note that you can also enter your mysqldump command as shown next, which are equivalent to the previous command:

mysqldump--opt-u root-p drupaldb > Drupaldb-20090505.sql

  

In both of these examples, the 20090505 portion of the filename just indicates today's date, May 5, 2009. (Happy Cinco de Mayo.:)

MySQL backup-the general form of mysqldump

That is one specific example of the mysqldump command. The general form of the backup command was shown here:

mysqldump--opt-u username-p database-name > Backup-file-name

  

where

    • usernameCan root is, if you know root the password, or it can be is the name of the MySQL user that owns your database.
    • database-nameis the name of your database, which drupaldb .
    • backup-file-nameis the name of the backup file, want to create. This would be a plain text file, the mysqldump command creates for you.
MySQL Database backup shell script

I just created a new MySQL database backup (dump) shell script to automate MySQL backups. In addition to creating the This shell script, I ' ve added new MySQL command line options is shown in this example. If you need to the use additional mysqldump command line options, see this article for more information.

MySQL backup-how to backup a MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.