Home  >  Article  >  Database  >  How to backup mysql

How to backup mysql

藏色散人
藏色散人Original
2019-05-10 14:20:4016406browse

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]

Back up one or more specified databases

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

Back up all databases

shell>mysqldump [option] --all-database

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

(2) Back up database test

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

(3) Back up database test Table emp

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

(4) Back up tables emp and dept

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

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 ','

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

Statement:
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