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
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
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!