[1] When the database is deleted after the recovery method
First, create a test database.
Mysql-u root-p123123← log in to MySQL server with root enter password:← Enter the root user password for MySQL
Welcome toThe MySQL Monitor. CommandsEnd with or\g. Your MySQL Connection ID is 8 toServer version:4.1. -Type'Help ;' or '\h' forHelp. Type'\c' toclear the buffer. MySQL> Create DatabaseTest ← Set up a test database for testing Query OK,1Row affected (0.00sec) MySQL> Usetest← Connect to this databaseDatabasechanged MySQL> Create TableTest (numint, namevarchar( -)); ← Create a table in the database Query OK,0Rows Affected (0.07sec) MySQL> Insert intoTestValues(1,'Hello,centos'); ← Insert a value into this table (here "Hello,centos" for example) Query OK,1Row affected (0.02sec) MySQL> Select * fromTest ← Viewing content in a database+------+-----------------+ | num | name | +------+-----------------+ |1 |Hello,centos|← Confirm the existence of values just inserted into the table+------+------------------+ 1 row in Set (0.01 sec)Mysql> Exit← Exiting MySQL server Bye
Then, run the database backup script that you just created, and back up the database that you just established for the test. (mysqldump Backup)
Next, we log on to the MySQL server again and delete the database test that we just built for testing so that we can test the success of the data recovery.
Mysql> Usetest← connect to test database ReadingTableInformation forCompletion ofTable andcolumnNames you can turnoffThis feature toGet a quicker startup with-ADatabasechanged MySQL>DropTableTest ← Delete the table in the data Query OK,0Rows Affected (0.04sec) MySQL>DropDatabaseTest ← Delete test with database test Query OK,0Rows Affected (0.01sec) MySQL>show databases;+---------------+ | Database | +---------------+ |Mysql|← Verify test database no longer exists, has been deleted+---------------+ 1RowinchSet(0.01sec)
mysql> CREATE DATABASE test; ← Re-create DATABASE test
Query OK, 0 rows affected (0.01 sec)
MySQL > exit ← Quit MySQL server Bye
Above, we are tantamount to simulating the process of database corruption. Next, the database is "destroyed" after the use of backup to restore the method.
[[email protected] ~]#/Bin/Cp-Rf/Backup/Mysql/Test/ /var/Lib/Mysql/← Copy the backed up database test to the appropriate directory[[email protected] ~]# mysql-uroot-p123123 Test </alidata/www/db/bak_data/alidata/www/db/bak_data
MySQL Data recovery