国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

MySQL數(shù)據(jù)庫(kù)恢復(fù)(使用mysqlbinlog命令)

2024-07-24 12:44:18
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
1:開(kāi)啟binlog日志記錄
修改mysql配置文件mysql.ini,在[mysqld]節(jié)點(diǎn)下添加
復(fù)制代碼 代碼如下:

# log-bin
log-bin = E:/log/logbin.log

路徑中不要包含中文和空格。重啟mysql服務(wù)。通過(guò)命令行停止和啟動(dòng)mysql服務(wù)
復(fù)制代碼 代碼如下:

c:/>net stop mysql;
c:/>net start mysql;

進(jìn)入命令行進(jìn)入mysql并查看二進(jìn)制日志是否已經(jīng)啟動(dòng)
Sql代碼
復(fù)制代碼 代碼如下:

mysql>show variables like 'log_%';

日志成功開(kāi)啟后,會(huì)在E:/log/目錄下創(chuàng)建logbin.index和logbin.000001兩個(gè)文件。logbin.000001就是數(shù)據(jù)庫(kù)的備份文件,以后就可以通過(guò)此文件對(duì)數(shù)據(jù)庫(kù)進(jìn)行恢復(fù)操作。

2:查看備份的二進(jìn)制文件
Sql代碼
復(fù)制代碼 代碼如下:

c:/mysql/bin/>mysqlbinlog e:/log/logbin.000001

日后記錄的操作多了,命令行方式基本就用不上了。可以使用將日志導(dǎo)出文件的方式來(lái)查看日志內(nèi)容
2.1 導(dǎo)出
Xml代碼
復(fù)制代碼 代碼如下:

c:/mysql/bin/>mysqlbinlog e:/log/logbin.000001 > e:/log/log.txt

">": 導(dǎo)入到文件中; ">>": 追加到文件中
如果有多個(gè)日志文件
Sql代碼
復(fù)制代碼 代碼如下:

c:/mysql/bin/> mysqlbinlog e:/log/logbin.000001 > e:/log/log.sql
c:/mysql/bin/> mysqlbinlog e:/log/logbin.000002 >> e:/log/log.sq

2.2 按指定位置導(dǎo)出:
Sql代碼
復(fù)制代碼 代碼如下:

c:/mysql/bin/>mysqlbinlog --start-position=185 --stop-position=338 e:/log/logbin.000001 > e:/log/log3.txt

2.3 按指定時(shí)間導(dǎo)出:
Xml代碼
復(fù)制代碼 代碼如下:

c:/mysql/bin/>mysqlbinlog --start-datetime="2010-01-07 11:25:56" --stop-datetime="2010-01-07 13:23:50" e:/log/logbin.000001 > e:/log/log_by_date22.txt

3:從備份恢復(fù)數(shù)據(jù)庫(kù)
做了一次更新操作,之后日志的內(nèi)容如下:
Sql代碼
復(fù)制代碼 代碼如下:

/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#110107 13:23:50 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.53-community-log created 110107 13:23:50 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
ZqMmTQ8BAAAAZgAAAGoAAAABAAQANS4xLjUzLWNvbW11bml0eS1sb2cAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABmoyZNEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#110107 13:26:58 server id 1 end_log_pos 185 Query thread_id=44 exec_time=1 error_code=0
SET TIMESTAMP=1294378018/*!*/;
SET @@session.pseudo_thread_id=44/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1344274432/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!/C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 185
#110107 13:26:58 server id 1 end_log_pos 338 Query thread_id=44 exec_time=1 error_code=0
use ncl-interactive/*!*/;
SET TIMESTAMP=1294378018/*!*/;
UPDATE `t_system_id` SET `id_value`='3000' WHERE (`table_name`='t_working_day')
/*!*/;
# at 338
#110107 13:26:58 server id 1 end_log_pos 365 Xid = 8016
COMMIT/*!*/;
DELIMITER ;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#110107 13:23:50 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.53-community-log created 110107 13:23:50 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
ZqMmTQ8BAAAAZgAAAGoAAAABAAQANS4xLjUzLWNvbW11bml0eS1sb2cAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABmoyZNEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#110107 13:26:58 server id 1 end_log_pos 185 Query thread_id=44 exec_time=1 error_code=0
SET TIMESTAMP=1294378018/*!*/;
SET @@session.pseudo_thread_id=44/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1344274432/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!/C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 185
#110107 13:26:58 server id 1 end_log_pos 338 Query thread_id=44 exec_time=1 error_code=0
use ncl-interactive/*!*/;
SET TIMESTAMP=1294378018/*!*/;
UPDATE `t_system_id` SET `id_value`='3000' WHERE (`table_name`='t_working_day')
/*!*/;
# at 338
#110107 13:26:58 server id 1 end_log_pos 365 Xid = 8016
COMMIT/*!*/;
DELIMITER ;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鹤山市| 奉贤区| 项城市| 平阴县| 运城市| 龙川县| 旌德县| 兴城市| 桃源县| 宾川县| 疏勒县| 定西市| 沛县| 湟中县| 岚皋县| 平安县| 苍梧县| 罗田县| 郎溪县| 虹口区| 师宗县| 栾川县| 桦甸市| 田林县| 吴堡县| 吉林省| 莱芜市| 桃园县| 黑龙江省| 民乐县| 邯郸县| 南漳县| 青海省| 德令哈市| 灌云县| 奎屯市| 建德市| 毕节市| 长垣县| 阿拉善盟| 梨树县|