Copy MySql database file backup database in linux

Source: Internet
Author: User

Generally, MySql database backup can be performed in two ways: Exporting SQL statements directly or SQL storage files in other formats that are easy to import, using SQL statements or some visual clients to export data, this method is very simple and does not need to be repeated. Another method is to copy the database file and convert the database file into an SQL file. This article introduces this method.

① Find the location where the database files are stored. The suffixes of MySql files include *. MYD, *. MYI, and *. frm;

 
 
  1. find / -name *.MYD 

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2259325F4-0.png "border =" 0 "alt =" "/>

② Enter the database storage file directory;

 
 
  1. cd /opt/lanmp/mysql-5.1.63/win/data/ 

③ Use the copy command to copy all the data;

 
 
  1. copy mysql /home 

④ At this time, you only need to convert these database files into SQL files, which is also the focus of this Article. If you need to import the SQL files with commands, you can;

⑤ Create a new database named mysqlbak and paste the copied folder into the data folder of the new database;

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/225932LL-1.png "border =" 0 "alt =" "/>

 
 
  1. find / -name mysqlbak 

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2259321329-2.png "border =" 0 "alt =" "/>

 
 
  1. cd /home/mysql 
  2. copy * /www/wdlinux/mysql-5.1.63/var/mysqlbak/ 

⑥ Now we can see the data in the new database mysqlbak, which is the same as the data in the original database mysql;

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2259324935-3.png "border =" 0 "alt =" "/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/225932B60-4.png "border =" 0 "alt =" "/>

7. Use commands to export database files.

 
 
  1. mysqldump -uroot -p mysqlbak > /home/mysql.sql 

The mysql. SQL file in the home folder is a database file that is easy to import. Note that all operations must be completed using commands in the operating system, rather than using tools. In actual operation, we often encounter the inconsistency between the database file version and the database version, or the inconsistency between the new and old database versions, in addition, unexpected problems such as incompatibility between the data server version and client tools may occur. If this is the case, "1577: cannot proceed because system tables used by Event sched1_were found damaged at server start "error. Speaking of this, in fact, this article also provides a method to open mysql database files, if there are only a bunch *. MYD ,*. MYI ,*. in the frm file, perform Step 5 to Step 5.

This article is from the "Rainbow cat walking across the world" blog!

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.