mysql mysqldump数据库备份与还原
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-14 11:33:21 浏览: 评论:0
mysqldump是mysql一个数据库常用工具,我们经常用它来实现数据和备份如,数据导入导出,本文章来介绍最基本数据库导出与表导现的代码.
- #mysqldump 数据库名 >数据库备份名
- #mysqldump -A -u用户名 -p密码 数据库名>数据库备份名
- #mysqldump -d -A --add-drop-table -uroot -p >xxx.sql
导出整个数据库database,代码如下:
mysqldump –opt -uroot -ppassword database > dump.sql
导出单个数据表table,代码如下:
mysqldump –opt –add-drop-table -uroot -ppassword database table > dump.sql
国外网站数据导入导出说明:For the impatient, here is the quick snippet of how backup and restore MySQL database using mysqldump:代码如下:
- backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
- restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Backup a single database:
This example takes a backup of sugarcrm database and dumps the output to sugarcrm.sql,代码如下:
- # 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:
- --代码如下
- --
- -- 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-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', --phpfensi.com
- '7b886f23-571b-595b-19dd-487ce1eee867','2008-07-23 05:24:30',1);
- /*!40000 ALTER TABLE `accounts_contacts` ENABLE KEYS */;
- UNLOCK TABLES;
Tags: mysqldump mysql备份还原
相关文章
- ·mysql中常用命令导入导出数据命令(mysqldump,source)(2014-09-23)
- ·mysql备份提示 mysqldump:Got error:1016(2014-09-24)
- ·解决mysqldump:Got error:1044: Access denied for user的方法(2014-09-24)
- ·MySQL数据的导入与导出(mysqldump)方法(2014-09-27)
- ·mysql中利用mysqldump命令备份还原数据库(2014-09-28)
- ·mysqldump导出压缩(gzip)文件(2014-09-28)
- ·MySQL中mysqldump参数使用说明(2014-09-28)
- ·mysqldump备份与还原mysql数据库(2014-09-28)
- ·mysqldump导出存储过程实例(2014-09-28)
- ·shell实现mysql mysqldump实现数据全备份或增量备份(2014-09-29)
- ·mysql使用mysqldump定时自动备份数据库(2014-09-29)
- ·mysql利用mysqldump定时自动备份mysql数据库(2014-10-01)
- ·Mysql mysqldump命令备份所有数据库(2014-10-02)
- ·MySQL中mysqldump工具使用方法详解(2014-10-02)
- ·mysql中mysqldump备份还原与导入导出(2014-10-03)
- ·mysqldump备份数据后,新插入数据的datetime出错的问题(2014-10-04)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)