how do I import an sql file using the command line in mysql

27. Juli 2021 at 18:35

A common use of mysqldump is for making a backup of an entire database:

shell> mysqldump db_name > backup-file.sql

You can load the dump file back into the server like this:


shell> mysql db_name < backup-file.sql shell> zcat myfile.sql.gz | mysql -u root -ppassword mydb

The same in Windows command prompt:

mysql -p -u [user] [database] < backup-file.sql

Windows PowerShell

C:> cmd.exe /c "mysql -u root -p db_name < backup-file.sql"

MySQL command line

mysql> use db_name;
mysql> source backup-file.sql;

Please share this article von facebook & google plus or where you want, thank you!