How to import an SQL file using the command line in MySQL?
We always upload a a database in our sql through import. But when You import a huge/heavy size sql file then we need to used command.
It is very easy step :-
Try:
mysql -u username -p database_name < file.sql
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:
UNIX
shell> mysql db_name < backup-file.sql
The same in Windows command prompt:
mysql -p -u[user] [database] < backup-file.sql
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;
About The Author