MySQL Data recovery

Source: Internet
Author: User

[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.