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 back up the database under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to back up the database under Linux, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

During the development of the project, the backup of the database is very important, because the database is easy to be accidentally deleted, resulting in inestimable losses, so it is necessary to back up the database.

I. MySQL database backup

As shown in the figure: there are 6 databases in this system, and we take test as an example to demonstrate. Database backup instruction: mysqldump-u root-p test > / home/lzh/bak/test.sql where test represents the name of the database we want to back up, and'/ home/lzh/bak/test.sql' represents the path we want to store

When we enter the backup instructions, we are asked to enter the login password, and the database backup is completed after entering the password. At this point, we have backed up the database test to test.sql in the home/lzh/bak directory. Add-B parameter backup We add-B parameter when backing up the database, the backup file will have more statements to create the library than without-B. The instructions are as follows: mysqldump-B-u root-p test > / home/lzh/bak/2019-03-04/test.sql we also need to enter the login password for the database. Specify the compression command gzip compress backup stumysql1 database instructions as follows: mysqldump-B-u root-p test | gzip > / home/lzh/mysql_bak_B.sql.gz

Note: add pipes before compressing commands.

II. Restore of the database

Mysql command restore instructions are as follows: mysql-u root-p test use the source command to restore the database the first step: enter the mysql console, switch to the database we want to restore data, instructions such as: use database name second step: use the source command to restore, that is, we back up the .sql file, instructions such as: source / home/lzh/bak/test.sql decompression package to restore data gzip-d / home/mysql_bak_B.sql.gz.

The above is all the contents of the article "how to back up the database under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report