Home > Database > Mysql Tutorial > How to backup mysql

How to backup mysql

藏色散人
Release: 2020-09-16 16:37:47
Original
16435 people have browsed it

Logical backup in MySQL is to back up the data in the database as a text file, and the backed up file can be viewed and edited. In MySQL, use the mysqldump tool to complete the backup. There are three ways to call mysqldump:

(Recommended tutorial: mysql video tutorial)

Back up the specified database, or some tables in this database.

shell>mysqldump [option] db_name [tables]
Copy after login

Back up one or more specified databases

shell>mysqldump [option] --database DB1 [DB2 DB3...]
Copy after login

Back up all databases

shell>mysqldump [option] --all-database
Copy after login

If no table in the database is specified, all tables in all databases will be exported by default. The following are some examples of using the mysqldump tool for backup

(1) Back up all databases:

[cqh@localhost ~]$ mysqldump -uroot -p --all-database > all.sql
Copy after login

(2) Back up database test

[cqh@localhost ~]$ mysqldump -uroot -p test > test.sql
Copy after login

(3) Back up database test Table emp

[cqh@localhost ~]$ mysqldump -uroot -p test emp > emp.sql
Copy after login

(4) Back up tables emp and dept

[cqh@localhost ~]$ mysqldump -uroot -p test emp dept > emp_dept.sql
Copy after login

under database test (5) Back up all tables under database test as comma-separated text, and back up to /tmp :

[cqh@localhost ~]$ mysqldump -uroot -p -T /tmp test emp --fields-terminated-by ','
Copy after login

The above is the detailed content of How to backup mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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