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 and restore MySQL data

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

How to back up and restore MySQL data, 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.

Using mysqldump for backup and restore using mysqldump for backup

Mysqladmin stop-slave-uroot-pmysqldump-all-databases > fulldb.dumpmysqladmin start-slave-uroot-ptar-czf / tmp/dbdump.tar.gz. / fulldb.dump. / mysql-relay-log.info

In addition to backing up the dump of the entire database, we also need to back up the relay-log.info file (mysql-relay-log.info in the above example), which contains information similar to the following:

/ var/lib/mysql/mysql-relay-bin.000002720mysql-bin.0000023968

The red highlight indicates the execution status of the binary log on the current MySQL primary server. This data is critical when restoring the slave server. Restore using mysqldump

Mysql- uroot-p < / root/dbdump.dbstop slave;CHANGE MASTER TO MASTER_HOST='192.168.10.201', MASTER_USER='slave_user', MASTER_PASSWORD='abc@DEF', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=3968;start slave;show slave status\ G

In the state, if you have the following two lines, the slave server is working properly:

Slave_IO_Running: YesSlave_SQL_Running: Yes

Backup and restore backup database files using database files (Raw Data)

Service mariadb stoptar-- selinux-- acls-- xattrs-czPf / root/dbbackup.tar.gz / var/lib/mysql/service mariadb start

Note: the red parameter causes tar to back up both the selinux property and other ACL properties to prevent it from being unavailable after a restore to the target server. Restore database files

Service mariadb stoptar-- selinux-- acls-- xattrs-xzPf / root/dbbackup.tar.gz-C / service mariadb start

At the same time, these parameters need to be specified when restoring the data file. Troubleshooting error messa

150401 9:58:06 [ERROR] mysqld: File'/ var/lib/mysql/mysql-bin.index' not found (Errcode: 13) 150401 9:58:06 [ERROR] Aborting

Check SeLinux settings

Ll-Z mysql-bin.index-rw-rw----. Mysql mysql unconfined_u bject_r:var_lib_t:s0 mysql-bin.index

Solution method

SeLinux can be disabled (profile / etc/selinux/config)

SELINUX=disabled

Restart is required after modification.

You can also add the following parameters when compressing and decompressing with the tar command:

Tar-- selinux-- acls-- xattrs, 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