二、实践:
abc@ubuntu:~/Downloads/mysql$ mysqldump -uroot -p123 test > test.sql; abc@ubuntu:~/Downloads/mysql$ mysqldump -uroot -p123 test t2 > t2.sql; abc@ubuntu:~/Downloads/mysql$ more /tmp/emp.txt 1,z1 1,z2 1,z1 1,z2 3,z3 abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | | 56 | z56 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | +------+------+ abc@ubuntu:/usr/local/mysql/data$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(5,'z5')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(5,'z5')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;truncate emp;"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:45:31 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(1,'t1')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:02 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:37 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(3,'t3')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:51 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:47:35 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(53,'t53')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | | 53 | t53 | +------+------+ mysql> select * from payment limit 10; +------------+-------------+----------+-----------+--------+---------------------+---------------------+ | payment_id | customer_id | staff_id | rental_id | amount | payment_date | last_update | +------------+-------------+----------+-----------+--------+---------------------+---------------------+ | 1 | 1 | 1 | 76 | 2.99 | 2005-05-25 11:30:37 | 2006-02-15 22:12:30 | | 2 | 1 | 1 | 573 | 0.99 | 2005-05-28 10:35:23 | 2006-02-15 22:12:30 | | 3 | 1 | 1 | 1185 | 5.99 | 2005-06-15 00:54:12 | 2006-02-15 22:12:30 | | 4 | 1 | 2 | 1422 | 0.99 | 2005-06-15 18:02:53 | 2006-02-15 22:12:30 | | 5 | 1 | 2 | 1476 | 9.99 | 2005-06-15 21:08:46 | 2006-02-15 22:12:30 | | 6 | 1 | 1 | 1725 | 4.99 | 2005-06-16 15:18:57 | 2006-02-15 22:12:30 | | 7 | 1 | 1 | 2308 | 4.99 | 2005-06-18 08:41:48 | 2006-02-15 22:12:30 | | 8 | 1 | 2 | 2363 | 0.99 | 2005-06-18 13:33:59 | 2006-02-15 22:12:30 | | 9 | 1 | 1 | 3284 | 3.99 | 2005-06-21 06:24:45 | 2006-02-15 22:12:30 | | 10 | 1 | 2 | 4526 | 5.99 | 2005-07-08 03:17:05 | 2006-02-15 22:12:30 | +------------+-------------+----------+-----------+--------+---------------------+---------------------+ 10 rows in set (0.00 sec) mysql> create or replace view v_payment_myisam as select * from payment limit 15; Query OK, 0 rows affected (0.01 sec) mysql> Ctrl-C -- exit! Aborted abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysqlbinlog ./mysql-bin.000002 | mysql -uroot -p Enter password: mysqlbinlog: File './mysql-bin.000002' not found (Errcode: 13) abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;truncate emp;"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ sudo chmod 0777 -R ./mysql-bin.000002 abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ cd /usr/local/mysql/data/ abc@ubuntu:/usr/local/mysql/data$ sudo chmod -R 0777 ./mysql-bin.000002 abc@ubuntu:/usr/local/mysql/data$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:/usr/local/mysql/data$ cd ~/Downloads/mysql/ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 test < ./test-2015-11-08.dmp abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(5,'z5')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | z1 | | 1 | z2 | | 1 | z1 | | 1 | z2 | | 3 | z3 | | 5 | z5 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;truncate emp;"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ mysqlbinlog ./mysql-bin.000002 | mysql -uroot -p Enter password: ERROR 1051 (42S02) at line 25: Unknown table 'v_payment_myisam' abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:45:31 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(1,'t1')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:02 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:37 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(3,'t3')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:46:51 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | +------+------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "select now();"; +---------------------+ | now() | +---------------------+ | 2015-11-08 04:47:35 | +---------------------+ abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;insert into emp values(53,'t53')"; abc@ubuntu:~/Downloads/mysql$ mysql -uroot -p123 -e "use test;select * from emp order by id"; +------+------+ | id | info | +------+------+ | 1 | t1 | | 3 | t3 | | 53 | t53 | +------+------+