MySQL mysqldump database backup and restore

Source: Internet
Author: User

#mysqldump database name > Database backup Name
#mysqldump-A-u user name-p password database name > database backup Name
#mysqldump-D-A--add-drop-table-uroot-p >xxx.sql


Export the entire database

The code is as follows Copy Code

Mysqldump–opt-uroot-ppassword Database > Dump.sql

Export a single datasheet table

The code is as follows Copy Code

Mysqldump–opt–add-drop-table-uroot-ppassword database table > Dump.sql

Foreign website Data import and export instructions

For the impatient, this is the quick snippet a how backup and restore MySQL database using mysqldump:

The code is as follows Copy Code

Backup: # mysqldump-u Root-p[root_password] [database_name] > Dumpfilename.sql

restore:# mysql-u Root-p[root_password] [database_name] < Dumpfilename.sql


1. Backup a single database:
This example takes a backup of SugarCRM database and dumps the output to Sugarcrm.sql

The code is as follows Copy Code

# mysqldump-u Root-ptmppassword SugarCRM > Sugarcrm.sql

# mysqldump-u Root-p[root_password] [database_name] > Dumpfilename.sqlthe sugarcrm.sql'll contain drop table, creat e table and insert command for all the tables in the SugarCRM database. Following is a partial output of sugarcrm.sql, showing the dump information of accounts_contacts table:

The code is as follows Copy Code

--
--Table structure for table ' accounts_contacts '
--

DROP TABLE IF EXISTS ' accounts_contacts ';
SET @saved_cs_client = @ @character_set_client;
SET character_set_client = UTF8;
CREATE TABLE ' accounts_contacts ' (
' ID ' varchar not NULL,
' contact_id ' varchar default NULL,
' account_id ' varchar default NULL,
' date_modified ' datetime default NULL,
' Deleted ' tinyint (1) Not NULL default ' 0 ',
PRIMARY KEY (' id '),
KEY ' idx_account_contact ' (' account_id ', ' contact_id '),
KEY ' idx_contid_del_accid ' (' contact_id ', ' deleted ', ' account_id ')
) Engine=myisam DEFAULT Charset=utf8;
SET character_set_client = @saved_cs_client;

--
--Dumping data for table ' Accounts_contacts '
--

LOCK TABLES ' accounts_contacts ' WRITE;
/*!40000 ALTER TABLE ' accounts_contacts ' DISABLE KEYS * * *;
INSERT into ' accounts_contacts ' VALUES (' 6ff90374-26d1-5fd8-b844-4873b2e42091 ',
' 11ba0239-c7cf-e87e-e266-4873b218a3f9 ', ' 503a06a8-0650-6fdd-22ae-4873b245ae53 ',
' 2008-07-23 05:24:30 ', 1),
( ' 83126e77-eeda-f335-dc1b-4873bc805541 ', ' 7c525b1c-8a11-d803-94a5-4873bc4ff7d2 ',
' 80a6add6-81ed-0266-6db5-4873bc54bfb5 ', ' 2008-07-23 05:24:30 ', 1),
(' 4e800b97-c09f-7896-d3d7-48751d81d5ee ', ' F241c222-b91a-d7a9-f355-48751d6bc0f9 ',
' 27060688-1f44-9f10-bdc4-48751db40009 ', ' 2008-07-23 05:24:30 ', 1),
( ' C94917ea-3664-8430-e003-487be0817f41 ', ' c564b7f3-2923-30b5-4861-487be0f70cb3 ',
' c71eff65-b76b-cbb0-d31a-487be06e4e0b ', ' 2008-07-23 05:24:30 ', 1),
(' 7dab11e1-64d3-ea6a-c62c-487ce17e4e41 ', ' 79d6f6e5-50e5-9b2b-034b-487ce1dae5af ',
' 7b886f23-571b-595b-19dd-487ce1eee867 ', ' 2008-07-23 05:24:30 ', 1);
/*!40000 ALTER TABLE ' accounts_contacts ' ENABLE the KEYS */;
UNLOCK TABLES;

MySQL mysqldump command Implementation data Export import click View

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.