Home > Database > Mysql Tutorial > body text

What are the common backup methods for mysql?

王林
Release: 2023-05-31 12:28:59
forward
701 people have browsed it

1. Use tar to package the folder backup. The database can be saved directly in the data folder, but it takes up a lot of space. It can be compressed and saved with tar packaging.

[root@localhost ~]# systemctl stop mysqld
[root@localhost ~]# tar Jcvf /opt/mysql-$(date +%F).tar.xz /usr/local/mysql/data/
[root@localhost ~]# ls /opt/
mysql-2021-10-25.tar.xz
[root@localhost ~]# systemctl start mysqld
Copy after login

2. Use the mysqldump tool to back up and control the backup content more flexibly. For example, you can back up several tables or libraries separately.

[root@localhost ~]# mysqldump -u root -p123456 --databases info > /opt/info.sql  #对info库进行备份
[root@localhost ~]# ls /opt/
info.sql
Copy after login

The above is the detailed content of What are the common backup methods for mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template