Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make mysqldump backup

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

How to carry out mysqldump backup, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Mysqldump

Using mysql's dump boot library table recently, record how the command is used:

Mysqldump backup:

Mysqldump-u username-p password-h host database a-w "sql condition"-- lock-all-tables > path

Case study:

Mysqldump-uroot-p1234-hlocalhost db1 a-w "id in (select id from b)"-- lock-all-tables > c:\ aa.txt

Mysqldump restore:

Mysqldump-u username-p password-h host database path

Mysqldump-uroot-p1234 dbname a-- where "tag='88'"-- no-create-info > c:\ a.sql

Mysqldump by Import:

Mysqldump-u username-p password-h host database db_name.sql

Use the following SQL to back up the Innodb table:

/ usr/local/mysql/bin/mysqldump-uyejr-pyejr "

-default-character-set=utf8-opt-extended-insert=false "

-- triggers-R-- hex-blob-- single-transaction db_name > db_name.sql

In addition, if you want to implement online backup, you can also use the-- master-data parameter, as follows:

/ usr/local/mysql/bin/mysqldump-uyejr-pyejr "

-default-character-set=utf8-opt-master-data=1 "

-- single-transaction-- flush-logs db_name > db_name.sql

It just requests to lock the table at the beginning, then refreshes the binlog, and then adds the CHANGE MASTER statement to the exported file to specify the binlog location of the current backup. If you want to restore the file to slave, you can do it this way.

1.2 restore

The file backed up with mysqldump is a SQL script that can be poured directly, and there are two ways to import the data.

Directly use the mysql client

For example:

/ usr/local/mysql/bin/mysql-uyejr-pyejr db_name < db_name.sql

Use SOURCE grammar (the experiment is not successful! )

In fact, this is not a standard SQL syntax, but a feature provided by the mysql client, such as:

SOURCE / tmp/db_name.sql

You need to specify the absolute path to the file, and it must be a file that the mysqld running user (such as nobody) has permission to read.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report