Backup and Restore MySQL Database Using mysqldump
Backup and Restore MySQL Database Using mysqldump
by Ramesh Natarajan on September 22, 2008ShareThis
[mysqldump - MySQL Backup & Restore]mysqldump is an effective tool to backup MySQL database. It creates a *.sql file with DROP table, CREATE table and INSERT into sql-statements of the source database. To restore the database, execute the *.sql file on destination database. For MyISAM, use mysqlhotcopy method that we explained earlier, as it is faster for MyISAM tables.
Using mysqldump, you can backup a local database and restore it on a remote database at the same time, using a single command. In this article, let us review several practical examples on how to use mysqldump to backup and restore.
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
How To Backup MySQL database
1. 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.sql
The 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` (`ac
相关文档:
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
//===========================================
// 程序: mysql-Based Session Class
// 功能: 基于mysql存储的 Session 功能类
// 作者: yejr
// 网站: http://imysql.cn
// 时间: 2007- ......
MySQL可以为不同的用户分配严格的、复杂的权限。这些操作大多都可以用SQL指令Grant(分配权限)和Revoke(回收权限)来实现。 Grant可以把指定的权限分配给特定的用户,如果这个用户不存在,则会创建一个用户。
Grant 常用格式:
grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 ide ......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......
conn.php
<?php
/*
* Created on 2010-1-6
* Author:CHAUVET
* Function:连接字符串
*/
$conn=@mysql_connect("localhost","root","")or die("连接数据库出错!");
mysql_select_db("newdb",$conn);
mysql_query("set names 'gb2312'");
function ReplaceSom ......
原文转自:http://hi.baidu.com/jackli00/blog/item/21b2e242025bfa1473f05d24.html
Mysql开启日志
2008-11-18 11:23
是否启用了日志
mysql>show variables like 'log_bin';
怎样知道当前的日志
mysql> show master status;
看二进制日志文件用mysqlbinlog
shell>mysqlbinlog mail-bin.000001(要写绝对问题 ......