教你如何恢复使用MEB备份的MySQL数据库

恢复使用MEB备份的MySQL数据库,执行一个普通备份

[root@test bin]# ./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf --socket=/data/mysql5.5/mysql.sock --user=root --backup-dir=/backup/5.5/normal --password backup
MySQL Enterprise Backup version 3.8.2 [2013/06/18]
Copyright (c) 2003, 2012,Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf
--socket=/data/mysql5.5/mysql.sock --user=root
--backup-dir=/backup/5.5/normal --password backup
Enter password:
mysqlbackup: INFO: MySQL server version is '5.5.25-log'.
mysqlbackup: INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup' run mysqlbackup
prints "mysqlbackup completed OK!".

--------------------------------------------------------------------

Server Repository Options:

--------------------------------------------------------------------

datadir = /data/mysql5.5/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql5.5/
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = Null
innodb_checksum_algorithm = innodb

--------------------------------------------------------------------

Backup Config Options:

--------------------------------------------------------------------

datadir = /backup/5.5/normal/datadir
innodb_data_home_dir = /backup/5.5/normal/datadir
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /backup/5.5/normal/datadir
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
mysqlbackup: INFO: Unique generated backup id for this is 13851351066141087
mysqlbackup: INFO: Uses posix_fadvise() for performance optimization.
mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
131122 23:45:08 mysqlbackup: INFO: Full Backup operation starts with following threads
1 read-threads  6 process-threads  1 write-threads
131122 23:45:08 mysqlbackup: INFO: System tablespace file format is Antelope.
131122 23:45:08 mysqlbackup: INFO: Starting to copy all innodb files...
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/ibdata1 (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Found checkpoint at lsn 3406087628.
131122 23:45:08 mysqlbackup: INFO: Starting log scan from lsn 3406087168.
131122 23:45:08 mysqlbackup: INFO: Copying log...
131122 23:45:08 mysqlbackup: INFO: Log copied, lsn 3406087628.
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_qs_variables.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_script_report_data.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_split_column_names_table.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_sql_tokens.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_known_thread_states.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_named_scripts.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_script_statements.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_waits.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/help_content.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/metadata.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/numbers.ibd (Antelope file format).
131122 23:45:08 mysqlbackup: INFO: Copying /data/mysql5.5/zwc/t2.ibd (Antelope file format).
mysqlbackup: Progress in MB: 200 400
131122 23:45:20 mysqlbackup: INFO: Completing the copy of innodb files.
131122 23:45:21 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
131122 23:45:21 mysqlbackup: INFO: Starting to lock all the tables...
131122 23:45:21 mysqlbackup: INFO: All tables are locked and flushed to disk
131122 23:45:21 mysqlbackup: INFO: Opening backup source directory '/data/mysql5.5/'
131122 23:45:21 mysqlbackup: INFO: Starting to backup all non-innodb files in
subdirectories of '/data/mysql5.5/'
131122 23:45:21 mysqlbackup: INFO: Copying the database directory 'common_schema'
131122 23:45:21 mysqlbackup: INFO: Copying the database directory 'mysql'
131122 23:45:21 mysqlbackup: INFO: Copying the database directory 'performance_schema'
131122 23:45:21 mysqlbackup: INFO: Copying the database directory 'test'
131122 23:45:21 mysqlbackup: INFO: Copying the database directory 'zwc'
mysqlbackup: Progress in MB: 600 800
131122 23:45:33 mysqlbackup: INFO: Completing the copy of all non-innodb files.
131122 23:45:35 mysqlbackup: INFO: A copied database page was modified at 3406087628.
(This is the highest lsn found on page)
Scanned log up to lsn 3406090810.
Was able to parse the log up to lsn 3406090810.
Maximum page number for a log record 315
131122 23:45:35 mysqlbackup: INFO: All tables unlocked
131122 23:45:35 mysqlbackup: INFO: All MySQL tables were locked for 13.758 seconds.
131122 23:45:35 mysqlbackup: INFO: Full Backup operation completed successfully.
131122 23:45:35 mysqlbackup: INFO: Backup created in directory '/backup/5.5/normal'
131122 23:45:35 mysqlbackup: INFO: MySQL binlog position: filename ZWC-TEST.000024, position 16178
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN         : 3406087168
End LSN          : 3406090810
-------------------------------------------------------------
mysqlbackup completed OK!

或者压缩备份

[root@test bin]# ./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf --socket=/data/mysql5.5/mysql.sock --user=root --backup-dir=/backup/5.5/compress --compress --password backup
MySQL Enterprise Backup version 3.8.2 [2013/06/18]
Copyright (c) 2003, 2012, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf
--socket=/data/mysql5.5/mysql.sock --user=root
--backup-dir=/backup/5.5/compress --compress --password backup
Enter password:
mysqlbackup: INFO: MySQL server version is '5.5.25-log'.
mysqlbackup: INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup' run mysqlbackup
prints "mysqlbackup completed OK!".

--------------------------------------------------------------------

Server Repository Options:

--------------------------------------------------------------------

datadir = /data/mysql5.5/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql5.5/
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = Null
innodb_checksum_algorithm = innodb

--------------------------------------------------------------------

Backup Config Options:

--------------------------------------------------------------------

datadir = /backup/5.5/compress/datadir
innodb_data_home_dir = /backup/5.5/compress/datadir
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /backup/5.5/compress/datadir
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
mysqlbackup: INFO: Unique generated backup id for this is 13851352214073555
mysqlbackup: INFO: Uses posix_fadvise() for performance optimization.
mysqlbackup: INFO: Creating 18 buffers each of size 16794070.
131122 23:47:03 mysqlbackup: INFO: Compress Backup operation starts with following threads
1 read-threads  6 process-threads  1 write-threads
131122 23:47:03 mysqlbackup: INFO: System tablespace file format is Antelope.
131122 23:47:03 mysqlbackup: INFO: Starting to copy all innodb files...
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/ibdata1 (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Found checkpoint at lsn 3406092146.
131122 23:47:03 mysqlbackup: INFO: Starting log scan from lsn 3406091776.
131122 23:47:03 mysqlbackup: INFO: Copying log...
131122 23:47:03 mysqlbackup: INFO: Log copied, lsn 3406092146.
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_qs_variables.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_script_report_data.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_split_column_names_table.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_global_sql_tokens.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_known_thread_states.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_named_scripts.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_script_statements.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/_waits.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/help_content.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/metadata.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/common_schema/numbers.ibd (Antelope file format).
131122 23:47:03 mysqlbackup: INFO: Copying /data/mysql5.5/zwc/t2.ibd (Antelope file format).
mysqlbackup: Progress in MB: 200 400
131122 23:47:11 mysqlbackup: INFO: Completing the copy of innodb files.
131122 23:47:14 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
131122 23:47:14 mysqlbackup: INFO: Starting to lock all the tables...
131122 23:47:14 mysqlbackup: INFO: All tables are locked and flushed to disk
131122 23:47:14 mysqlbackup: INFO: Opening backup source directory '/data/mysql5.5/'
131122 23:47:14 mysqlbackup: INFO: Starting to backup all non-innodb files in
subdirectories of '/data/mysql5.5/'
131122 23:47:14 mysqlbackup: INFO: Copying the database directory 'common_schema'
131122 23:47:14 mysqlbackup: INFO: Copying the database directory 'mysql'
131122 23:47:15 mysqlbackup: INFO: Copying the database directory 'performance_schema'
131122 23:47:15 mysqlbackup: INFO: Copying the database directory 'test'
131122 23:47:15 mysqlbackup: INFO: Copying the database directory 'zwc'
mysqlbackup: Progress in MB: 600 800
131122 23:47:26 mysqlbackup: INFO: Completing the copy of all non-innodb files.
131122 23:47:28 mysqlbackup: INFO: A copied database page was modified at 3406092146.
(This is the highest lsn found on page)
Scanned log up to lsn 3406095314.
Was able to parse the log up to lsn 3406095314.
Maximum page number for a log record 319
131122 23:47:29 mysqlbackup: INFO: All tables unlocked
131122 23:47:29 mysqlbackup: INFO: All MySQL tables were locked for 14.330 seconds.
131122 23:47:29 mysqlbackup: INFO: Compressed 496 MB of data files to 200577 kbytes (compression 60.51%).
131122 23:47:29 mysqlbackup: INFO: Compress Backup operation completed successfully.
131122 23:47:29 mysqlbackup: INFO: Backup created in directory '/backup/5.5/compress'
131122 23:47:29 mysqlbackup: INFO: MySQL binlog position: filename ZWC-TEST.000024, position 24831
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN         : 3406091776
End LSN          : 3406095314
-------------------------------------------------------------
mysqlbackup completed OK!

停止MySQL服务

[root@test mysql5.5]# /service/mysql5.5/bin/mysqladmin shutdown -uroot -p

删除数据目录里的文件

[root@test mysql5.5]# rm -rf common_schema/ mysql/ performance_schema/ test/ zwc/

从备份中还原

[root@test bin]# ./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf --backup-dir=/backup/5.5/normal apply-log
MySQL Enterprise Backup version 3.8.2 [2013/06/18]
Copyright (c) 2003, 2012, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf
--backup-dir=/backup/5.5/normal apply-log
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'apply-log' run mysqlbackup
prints "mysqlbackup completed OK!".

--------------------------------------------------------------------

Backup Config Options:

--------------------------------------------------------------------

datadir = /backup/5.5/normal/datadir
innodb_data_home_dir = /backup/5.5/normal/datadir
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /backup/5.5/normal/datadir
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
mysqlbackup: INFO: Uses posix_fadvise() for performance optimization.
mysqlbackup: INFO: Creating 14 buffers each of size 65536.
131122 23:59:39 mysqlbackup: INFO: Apply-log operation starts with following threads
1 read-threads  1 process-threads
131122 23:59:39 mysqlbackup: INFO: ibbackup_logfile's creation parameters:
start lsn 3406087168, end lsn 3406090810,
start checkpoint 3406087628.
InnoDB: Doing recovery: scanned up to log sequence number 3406090810
mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 Setting log file size to 536870912
InnoDB: Progress in MB: 100 200 300 400 500
Setting log file size to 536870912
InnoDB: Progress in MB: 100 200 300 400 500
Setting log file size to 536870912
InnoDB: Progress in MB: 100 200 300 400 500
131123 00:00:01 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to
lsn 3406090810.
mysqlbackup: INFO: Last MySQL binlog file position 0 16178, file name ./ZWC-TEST.000024
131123 00:00:01 mysqlbackup: INFO: The first data file is '/backup/5.5/normal/datadir/ibdata1'
and the new created log files are at '/backup/5.5/normal/datadir'
131123 00:00:01 mysqlbackup: INFO: Apply-log operation completed successfully.
131123 00:00:01 mysqlbackup: INFO: Full backup prepared for recovery successfully.
mysqlbackup completed OK![root@test bin]# ./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf --backup-dir=/backup/5.5/normal copy-back
MySQL Enterprise Backup version 3.8.2 [2013/06/18]
Copyright (c) 2003, 2012, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf
--backup-dir=/backup/5.5/normal copy-back
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'copy-back' run mysqlbackup
prints "mysqlbackup completed OK!".

--------------------------------------------------------------------

Server Repository Options:

--------------------------------------------------------------------

datadir = /data/mysql5.5
innodb_data_home_dir = /data/mysql5.5
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql5.5
innodb_log_files_in_group = 3
innodb_log_file_size = 512M
innodb_page_size = Null
innodb_checksum_algorithm = innodb

--------------------------------------------------------------------

Backup Config Options:

--------------------------------------------------------------------

datadir = /backup/5.5/normal/datadir
innodb_data_home_dir = /backup/5.5/normal/datadir
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /backup/5.5/normal/datadir
innodb_log_files_in_group = 3
innodb_log_file_size = 536870912
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
mysqlbackup: INFO: Uses posix_fadvise() for performance optimization.
mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
131123 00:00:44 mysqlbackup: INFO: Copy-back operation starts with following threads
1 read-threads  1 write-threads
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/ibdata1.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_global_qs_variables.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_global_script_report_data.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_global_split_column_names_table.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_global_sql_tokens.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_known_thread_states.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_named_scripts.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_script_statements.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/_waits.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/help_content.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/metadata.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/common_schema/numbers.ibd.
131123 00:00:45 mysqlbackup: INFO: Copying /backup/5.5/normal/datadir/zwc/t2.ibd.
mysqlbackup: Progress in MB: 200 400
131123 00:00:54 mysqlbackup: INFO: Copying the database directory 'common_schema'
131123 00:00:55 mysqlbackup: INFO: Copying the database directory 'mysql'
131123 00:00:55 mysqlbackup: INFO: Copying the database directory 'performance_schema'
131123 00:00:55 mysqlbackup: INFO: Copying the database directory 'test'
131123 00:00:55 mysqlbackup: INFO: Copying the database directory 'zwc'
mysqlbackup: Progress in MB: 600 800
131123 00:01:06 mysqlbackup: INFO: Completing the copy of all non-innodb files.
131123 00:01:06 mysqlbackup: INFO: Copying the log file 'ib_logfile0'
mysqlbackup: Progress in MB: 1000 1200 1400
131123 00:01:16 mysqlbackup: INFO: Copying the log file 'ib_logfile1'
mysqlbackup: Progress in MB: 1600 1800
131123 00:01:27 mysqlbackup: INFO: Copying the log file 'ib_logfile2'
mysqlbackup: Progress in MB: 2000 2200 2400
131123 00:01:38 mysqlbackup: INFO: Copy-back operation completed successfully.
131123 00:01:38 mysqlbackup: INFO: Finished copying backup files to '/data/mysql5.5'
mysqlbackup completed OK!

设置权限,启动MySQL服务

[root@test mysql5.5]# chown -R mysql.mysql *
[root@test mysql5.5]# /service/mysql5.5/bin/mysqld_safe --defaults-file=/service/mysql5.5/my.cnf --basedir=/service/mysql5.5 --datadir=/data/mysql5.5 --user=mysql &
[1] 6525
[root@test mysql5.5]# 131123 00:04:00 mysqld_safe Logging to '/data/mysql5.5/test.err'.
131123 00:04:00 mysqld_safe Starting mysqld daemon with databases from /data/mysql5.5[root@test mysql5.5]# cat test.err
131123 00:04:00 mysqld_safe Starting mysqld daemon with databases from /data/mysql5.5
131123 0:04:00 InnoDB: The InnoDB memory heap is disabled
131123 0:04:00 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131123 0:04:00 InnoDB: Compressed tables use zlib 1.2.3
131123 0:04:00 InnoDB: Initializing buffer pool, size = 2.4G
131123 0:04:00 InnoDB: Completed initialization of buffer pool
131123 0:04:00 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 3406091276
131123 0:04:00 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 3406091710
131123 0:04:01 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 16178, file name ./ZWC-TEST.000024
131123 0:04:01 InnoDB: Waiting for the background threads to start
131123 0:04:02 InnoDB: 1.1.8 started; log sequence number 3406091710
131123 0:04:02 [Note] Recovering after a crash using ZWC-TEST
131123 0:04:02 [Note] Starting crash recovery...
131123 0:04:02 [Note] Crash recovery finished.
131123 0:04:02 [Note] Server hostname (bind-address): '0.0.0.0'; port: 30306
131123 0:04:02 [Note] - '0.0.0.0' resolves to '0.0.0.0';
131123 0:04:02 [Note] Server socket created on IP: '0.0.0.0'.
131123 0:04:02 [Warning] 'user' entry 'root@test' ignored in --skip-name-resolve mode.
131123 0:04:02 [Warning] 'user' entry '@test' ignored in --skip-name-resolve mode.
131123 0:04:02 [Warning] 'proxies_priv' entry '@ root@test' ignored in --skip-name-resolve mode.
131123 0:04:02 [Note] Event Scheduler: Loaded 0 events
131123 0:04:02 [Note] /service/mysql5.5/bin/mysqld: ready for connections.
Version: '5.5.25-log' socket: '/data/mysql5.5/mysql.sock' port: 30306 ZWC
131123 0:04:02 [Note] Event Scheduler: scheduler thread started with id 1

数据库已经恢复

[root@test mysql5.5]# /service/mysql5.5/bin/mysql -uroot -p -D zwc
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.25-log ZWC
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@linuxidc12:05:07>select count(*),now() from t1;
+----------+---------------------+
| count(*) | now()       |
+----------+---------------------+
| 10000000 | 2013-11-23 00:05:17 |
+----------+---------------------+
1 row in set (0.04 sec)
root@linuxidc12:05:17>select count(*),now() from t2;
+----------+---------------------+
| count(*) | now()       |
+----------+---------------------+
| 10000000 | 2013-11-23 00:05:19 |
+----------+---------------------+
1 row in set (2.91 sec)
(0)

相关推荐

  • mysql自动定时备份数据库的最佳方法(windows服务器)

    网上有很多关于window下Mysql自动备份的方法,可是真的能用的也没有几个,有些说的还非常的复杂,难以操作. 我们都知道mssql本身就自带了计划任务可以用来自动备份,可是mysql咱们要怎么样自动有备份呢? 教大家一个最简单的方法. 这个方法是用bat批处理来完成的. 假想环境:MySQL 安装位置:D:\Program Files\MySQL\MySQL Server 5.0\data 如图: 数据库名称为:952game数据库备份目的地:d:\db_bak\ (你想把数据库备份到哪个盘

  • mysql 5.6 从陌生到熟练之_数据库备份恢复的实现方法

    MySQL数据库使用命令行备份|MySQL数据库备份命令 例如: 数据库地址:127.0.0.1 数据库用户名:root 数据库密码:root 数据库名称: szldb 备份数据库到D盘跟目录 mysqldump -h127.0.0.1 -uroot -proot szldb > d:/backupfile.sql 备份到当前目录 备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库 mysqldump --add-drop-table -h127.0.0.

  • MySQL数据库备份以及常用备份工具集合

    一.数据库备份种类 按照数据库大小备份,有四种类型,分别应用于不同场合,下面简要介绍一下: 1.1完全备份 这是大多数人常用的方式,它可以备份整个数据库,包含用户表.系统表.索引.视图和存储过程等所有数据库对象.但它需要花费更多的时间和空间,所以,一般推荐一周做一次完全备份. 1.2事务日志备份 事务日志是一个单独的文件,它记录数据库的改变,备份的时候只需要复制自上次备份以来对数据库所做的改变,所以只需要很少的时间.为了使数据库具有鲁棒性,推荐每小时甚至更频繁的备份事务日志. 1.3差异备份 也

  • Mysql数据库增量备份的思路和方法

    MySQL数据库增量备份,在这之前修改我们的数据库配置文件/etc/my.cnf开启bin-log日志功能即可.接下来是我参考了下网上的一些方法,自己写的,主要还是要能学到他的一些思路和方法. #function:MYSQL增量备份 #version:1.0.0 #author:wangyanlin #date:2017/08/02 #---------------------------------------------------------------------------------

  • Mysql数据库性能优化三(分表、增量备份、还原)

    接上篇Mysql数据库性能优化二 对表进行水平划分     如果一个表的记录数太多了,比如上千万条,而且需要经常检索,那么我们就有必要化整为零了.如果我拆成100个表,那么每个表只有10万条记录.当然这需要数据在逻辑上可以划分.一个好的划分依据,有利于程序的简单实现,也可以充分利用水平分表的优势.比如系统界面上只提供按月查询的功能,那么把表按月拆分成12个,每个查询只查询一个表就够了.如果非要按照地域来分,即使把表拆的再小,查询还是要联合所有表来查,还不如不拆了.所以一个好的拆分依据是 最重要的

  • MySQL备份时排除指定数据库的方法

    使用mysqldump命令备份时候,--all-databases 可以备份所有的数据库. 使用ignore-table 还可以排除制定的表.但是,mysqldump没有参数可以排除数据库的. 要备份的数据库少的时候,可以通过mysqldump -uroot -p123456 --databases db1 db2 db3 > mysqldump.sql 这样来备份. 但是假如数据库有数十个的话,这样写起来很累人,也很low.解决办法还是有的,看下面: [下面演示用的mysql用户名的root,

  • MYSQL主从数据库同步备份配置的方法

    下文分步骤给大家介绍的非常详细,具体详情请看下文吧. 一.准备 用两台服务器做测试: Master Server: 192.0.0.1/Linux/MYSQL 4.1.12 Slave Server: 192.0.0.2/Linux/MYSQL 4.1.18 做主从服务器的原则是,MYSQL版本要相同,如果不能满足,最起码从服务器的MYSQL的版本必须高于主服务器的MYSQL版本 二.配置master服务器 1. 登录Master服务器,编辑my.cnf #vim /etc/my.cnf 在[m

  • MySQL数据库如何导入导出(备份还原)

    本文适用范围:全面阐述MySQL数据库的各种操作,分虚拟主机和服务器两种情况. 虚拟主机 1.通过PHPMyAdmin的导入导出功能,这个软件一般只支持几兆数据的导出,太大的数据可能会超时. 2.通过程序自带的数据库备份还原功能来操作,一些常见的PHP程序如DZ论坛等,后台都有数据库还原和备份的功能,方便我们转移空间数据. 3.如果您的数据库在朝暮数据购买,我们的管理面板支持一键备份和还原.点击备份按钮后,您可以到数据库对应的空间上通过FTP方式下载. 服务器或VPS 首先我们远程到服务器上(W

  • 教你如何恢复使用MEB备份的MySQL数据库

    恢复使用MEB备份的MySQL数据库,执行一个普通备份 [root@test bin]# ./mysqlbackup --defaults-file=/service/mysql5.5/my.cnf --socket=/data/mysql5.5/mysql.sock --user=root --backup-dir=/backup/5.5/normal --password backup MySQL Enterprise Backup version 3.8.2 [2013/06/18] Co

  • xtrabackup备份还原MySQL数据库

    mysqldump 备份鉴于其自身的某些特性(锁表,本质上备份出来insert脚本或者文本,不支持差异备份),不太适合对实时性要求比较高的情况 Xtrabackup可以解决mysqldump存在的上述的一些问题,生产环境应用的也会更多一些. 本文简单测试一下Xtrabackup对MySQL数据库的备份还原操作. 本着先把功能先撸起来再深入细节的原则,粗略地实现了一个备份还原,并未深入细节. 网上有不少xtrabackup的文章,因为环境不一样,有些需要配置xtrabackup的配置文件, 但是我

  • PHP备份/还原MySQL数据库的代码

    以下是代码: 一.备份数据库并下载到本地[db_backup.php] 复制代码 代码如下: <?php // 设置SQL文件保存文件名 $filename=date("Y-m-d_H-i-s")."-".$cfg_dbname.".sql"; // 所保存的文件名 header("Content-disposition:filename=".$filename); header("Content-type:a

  • 8种手动和自动备份MySQL数据库的方法

    作为流行的开源数据库管理系统,MySQL的使用者众多,为了维护数据安全性,数据备份是必不可少的.本文就为大家介绍几种适用于企业的数据备份方法. 使用MySQLDump进行MySQL备份 mysqldump是MySQL内置的工具,允许用户将数据库指定不同的选项备份到文件.服务器,甚至是压缩gzip文件中.mysqldump实用程序灵活,快速,可执行高级备份,并接受各种命令行参数,用户可通过这些参数来更改备份数据库的方式. Windows操作系统中的c:mysqlbin和Unix / Linux系统

  • 教你使用MongoDB导入导出备份数据

    目录 导出数据 mongodump mongoexport 恢复 mongorestore mongoimport 需要提前安装mongodb-database-tools参考:centos离线安装mongodb-database-tools 导出数据 常用的导出有两种:mongodump和mongoexport,两种方式的区别: 1.mongodump导出的文件格式是bson,mongoexport导出的文件格式是json和csv,可读性高. 2.mongodump只能指定到集合,mongoe

  • 教你自动恢复MySQL数据库的日志文件(binlog)

    如果MySQL服务器启用了二进制日志,你可以使用mysqlbinlog工具来恢复从指定的时间点开始 (例如,从你最后一次备份)直到现在或另一个指定的时间点的数据."mysqlbinlog:用于处理二进制日志文件的实用工具". 要想从二进制日志恢复数据,你需要知道当前二进制日志文件的路径和文件名.一般可以从选项文件(即my.cnf or my.ini,取决于你的系统)中找到路径.如果未包含在选项文件中,当服务器启动时,可以在命令行中以选项的形式给出.启用二进制日志的选项为 --log-b

  • mysql数据库备份及恢复命令 mysqldump,source的用法

    还原一个数据库:mysql -h localhost -u root -p123456 www<c:\www.sql 备份一个数据库:mysqldump -h localhost -u root -p123456 www > d:\www2008-2-26.sql //以下是在程序中进行测试 //$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile&qu

  • SqlServer批量备份多个数据库且删除3天前的备份

    废话不多说了,直接给大家贴代码了,具体代码如下所示: /******************************************* * 批量备份数据库且删除3天前的备份 *******************************************/ DECLARE @backupfile VARCHAR(1024) DECLARE @backdesc VARCHAR(1024) DECLARE @filename VARCHAR(1024) DECLARE @path VA

  • SQL 2005 ERROR:3145 解决办法(备份集中的数据库备份与现有的数据库不同)

    出现错误3145备份集中的数据库备份与现有的数据库不同 网上解决办法不少,测试下来都是半吊子,错误还是存在 摸索中,解决了 1.新建一个与现有数据库重名的数据库 2.在查询窗口运行如下语句: 复制代码 代码如下: use master restore database AdventureWorks from disk = 'E:\databasebackup\AdventureWorks.bak' with replace, MOVE N'AdventureWorks_Data' TO N'C:

  • 最简便的MySql数据库备份方法MySQLdump第1/2页

    使用MYSQL进行数据库备份,有很正规的数据库备份方法,同其他的数据库服务器有相同的概念,但有没有想过,MySQL会有更简捷的使用文件目录的备份方法,而且又快有好.  一.数据备份捷径 因为这个方法没有得到官方正式文档的验证,我们暂称为试验吧.  目的:备份hostA主机中一个MySQL数据库TestA,并恢复到到hostB机中 试验环境: 操作系统:WinNT4.0,MySQL3.22.34,PHPMyAdmin 2.1.0 Chinaz 在hostA中安装MySQL数据库并建立TestA数据

随机推荐