How to import a .sql file in MySQL? I am trying to import a .sql file using MySQL Workbench and I get this error:

ERROR 1046 (3D000) at line 28: No database selected


I have first created an empty database called with the same name as the .sql file but it doesn't work.
I have also tried to do it with the mysql command client using:

mysqldump -u root database &gt; file.sql 


But it says a have an error in my SQL syntax. Furthermore, I don't know the path where I have to set the file.sql.
Export:

mysqldump -u username –-password=your_password database_name &gt; file.sql


Import:

mysql -u username –-password=your_password database_name &lt; file.sql