How to backup and import database in mysql

小云云
Release: 2023-03-20 17:34:02
Original
2399 people have browsed it


This article mainly shares with you how to back up and import the MySQL database. I hope it can help you.

Back up all databases
Execute from the system command line:mysqldump -uusername -ppassword --all-databases > all.sql

Back up a single database
Execute from the system command line:mysqldump -uusername -ppassword --databases db1 db2 > db.sql
Export db1 and db2 to a db.sql file.

Import database
1. Execute from the system command line:mysql -uusername -ppassword db1 < db1.sql
In this case, the db1 database must be built in advance.
2. Or execute under the mysql command line:source db1.sql
In this method, there is no need to create a database in advance, and the database will be created automatically.

Related recommendations:

Several methods of mysql database backup

Introduction to the use of MySQL database backup tool Mydumper

Detailed explanation of import and export of MySQL database

The above is the detailed content of How to backup and import database in 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!