Mysqlmysqldump database backup and restoration mysqldump
BitsCN.com
# Mysqldump database name> database backup name
# Mysqldump-A-u username-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:
Mysqldump-opt-uroot-ppassword database> dump. SQL
Export a single table
The code is as follows:
Mysqldump-opt-add-drop-table-uroot-ppassword database table> dump. SQL
Import and export of foreign website data
For the impatient, here is the quick snippet of how backup and restore MySQL database using mysqldump:
The code is as follows:
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 dumphotoshop/target = _ blank class = infotextkey> ps the output to sugarcrm. SQL
The code is as follows:
# Mysqldump-u root-ptmppassword sugarcrm> sugarcrm. SQL
# Mysqldump-u root-p [root_password] [database_name]> dumpfilename. sqlThe sugarcrm. SQL will contain drop table, create 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:
--
-- 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 (36) not null,
'Contact _ id' varchar (36) default NULL,
'Account _ id' varchar (36) 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-4153b245ae53 ',
'2017-07-23 05:24:30 ', 1 ),
('83126e77-eeda-f335-dc1b-4873bc805541 ', '7c525b1c-8a11-d803-94a5-4153bc4ff7d2 ',
'80a6add6-81ed-0266-6db5-4153bc54bfb5 ', '2017-07-23 05:24:30', 1 ),
('4e800b97-c09f-7896-d3d7-48751d81d5ee ', 'f241c222-b91a-d7a9-f355-48751d6bc0f9 ',
'2017-1f44-9f10-bdc4-48751db40009 ', '2017-07-23 05:24:30', 1 ),
('C94917ea-route 4-8430-e003-0000be0817f41 ', 'c564b7f3-2923-30b5-4861-0000be0f70cb3 ',
'C71eff65-b76b-cbb0-d31a-487be06e4e0b ', '2017-07-23 05:24:30', 1 ),
('Http: // response ',
'7b886f23-571b-595b-19dd-performance1eee867 ', '2017-07-23 05:24:30', 1 );
/*! 40000 alter table 'accounts _ contacts' enable keys */;
Unlock tables;
Mysql mysqldump command for data export import Click to view
For more details, see: http://www.111cn.net/database/mysql/42189.htm
BitsCN.com