Restoration of MySQL database after system crash

Source: Internet
Author: User
Tags mysql backup name database

With DedeCMS, PHPCMS, Empire, Discuz! With the popularization of well-known web management systems such as PHPWIND and WordPress, Mysql databases are widely used, and more problems are raised about Mysql, today, the Helper's house editor happened to see the article "restoring MySQL database after system crash" on the blog of the city without any help. I would like to share it with you and thank you for your hard work.

The original article is as follows:

The startup e server crashed due to hardware problems some time ago and was supported by the Network Center to migrate the server to the virtualization platform just built up by the school, the website of the system and asp + access database is restored immediately because it is saved on a non-system disk. However, because the MySQL database is installed in the system, data has never been empty. It took one day today to reinstall the MySQL Server N times and finally restore the database, but the permission issue has not been resolved. Write down the database recovery process, and wait for the permission questions.

In the beginning, the original system overwrites the previously stored Data ibdata1 to the newly installed MySQL Data DIRECTORY. However, although the file grows, the database does not return it. After reading a lot of documents, I found that ibdata1 only saves data in the database, but the table structure of the database is saved in another place.

Re-connect the original hard disk and find the original database structure and table structure file in C: \ Documents ents and Settings \ All Users \ Application Data \ MySQL Server 5.1 \ data, to overwrite the database file, stop MySQL and overwrite it, but then the MySQL service will no longer be started.

Then, when you try to reinstall the database, specify the database storage directory to the copied Date directory. After the installation, the system prompts that the original data file exists, but the last configuration of the installation has never been successful, I cannot change the MySQL version several times.

After installation, you can choose to overwrite the previously created table files and ibdata1. Then, the system starts successfully and restores the database files, but the permissions are insufficient. Only self-built. Relatively troublesome ···

Finally, we will introduce MySQL backup and recovery.

The MySql BACKUP command mysqldump is easy to use,

Copy to ClipboardReference: [www.bkjia.com] mysqldump-u username-p (password)-h host name Database Name> path/backup name. bak;

At the same time, you can use mysqldumpto access the data structure (tablename. SQL .pdf and data (tablename.txt)

Copy to ClipboardReference: [www.bkjia.com] mysqldump-u username-p (password)-h host name database name tablename1 tablename2> back. SQL
Or
Mysqldump-u user name-p (password)-h host name database name -- tab path -- opt database name.

For example:

Copy to ClipboardReference: [www.bkjia.com] mysqldump-u has-p has news> c: \ news. SQL

You can run the following mysql command to restore data:

Copy to ClipboardReference: [www.bkjia.com] mysql-u username-p (password)-h host name -- one-database Restore database name <path/backup name. bak, -- one-database is the database to be restored.

For example:

Copy to ClipboardReference: [www.bkjia.com] mysql-u published-p published news <c: \ news. SQL

(Brackets indicate that the password is not entered first, and Enter password during connection; if the password is blank, the default-p parameter can be used)

Related Article

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.