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

The method of creating full backup for Mysql Database

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The following mainly brings you the method of creating a full backup of Mysql database. I hope these words can bring you practical use, which is also the main purpose of this article that I edit Mysql database to create a full backup method. All right, don't talk too much nonsense, let's just read the following.

The first backup method:

Backup using tar packaged folders

Make a compressed backup of the database file directory data, using the xz format with high compression ratio

[root@localhost opt] # yum install-y xz

[root@localhost opt] # tar jcvf / opt/mysql-$ (date +% F) .tar.xz / usr/local/mysql/data/ # compressed backup

[root@localhost opt] # ls

Mysql-2018-08-30.tar.xz rh

Set scheduled tasks to execute automatically

[root@localhost opt] # crontab-e no crontab for root-using an empty one crontab: installing new crontab [root@localhost opt] # crontab-l 301 * tar jcvf / opt/mysql-$ (date +% F) / usr/local/mysql/data/ # set scheduled task automatic execution

Data recovery, decompress the backup file.

[root@localhost opt] # tar jxvf mysql-2018-08-30.tar.xz-C / usr/local/mysql/data/

The second backup method

Use the mysqldump tool to compress

Backup database

[root@localhost data] # mysql-uroot-p-e 'show databases 'Enter password: +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | school | | sys | | usr | [root@localhost ~] # mysqldump-uroot-p-databases school > / opt/school.sqlEnter password:

[root@localhost ~] # ls / opt

Mysql-2018-08-30.tar.xz rh school.sql

Delete database school

[root@localhost data] # mysql-uroot-p-e 'drop database school;show databases;'Enter password: +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | | usr | +-+

Database restore

The first option:

[root@localhost] # mysql-uroot-p

< /opt/school.sqlEnter password: [root@localhost ~]# mysql -uroot -pabc123 -e 'show databases;'mysql: [Warning] Using a password on the command line interface can be insecure.+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || school || sys || usr |+--------------------+ 第二种方案: [root@localhost ~]# mysql -uroot -pabc123mysql>

Source / opt/school.sql

Attached:

Mysqldump makes a full backup of a single library

Mysqldump-u root-p-- databases school > / opt/school.sql

Full backup of multiple data

Mysqldump-u root-p-- databases mysql school > / opt/school-mysql.sql

Back up all libraries

Mysqldump-u root-p-- all-databases > / opt/all.sql

Back up the table

Mysqldump-u root-p school info > / opt/info.sql

Back up the table structure

Mysqldump-u root-p-d school info > / opt/info.sql

For the above about the Mysql database to create a full backup method, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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