P粉9261742882023-08-24 09:06:53
mysqldump A common use is to back up the entire database:
mysqldump db_name > backup-file.sql
You can load the dump file back to the server as follows:
Unix
mysql db_name < backup-file.sql
Same in Windows Command Prompt:
mysql -p -u [user] [database] < backup-file.sql
cmd.exe /c "mysql -u root -p db_name < backup-file.sql"
MySQL command line
mysql> use db_name; mysql> source backup-file.sql;
P粉1037395662023-08-24 00:28:35
try:
mysql -u username -p database_name < file.sql
Check MySQL Options. p>
Note 1: It is best to use the full path of the SQL file file.sql
.
Note 2: Use -R
and --triggers
with mysqldump
to save the original database of routines and triggers. They are not copied by default.
Note 3 If the database does not exist yet and the exported SQL does not contain CREATE DATABASE
(exported using --no-create-db
or -n
option) before importing it.