Reputation: 1837
I created a database in mysql. I have a .sql file. how can i import it into my database via mysql workbench ?
Upvotes: 62
Views: 207712
Reputation: 29119
Upload sql file
Make sure to select your database in this award winning GUI:
Upvotes: 17
Reputation: 30625
For MySQL Workbench 8.0 navigate to:
Server > Data Import
A new tab called Administration - Data Import/Restore appears. There you can choose to import a Dump Project Folder or use a specific SQL file according to your needs. Then you must select a schema where the data will be imported to, or you have to click the New... button to type a name for the new schema.
Then you can select the database objects to be imported or just click the Start Import button in the lower right part of the tab area.
Having done that and if the import was successful, you'll need to update the Schema Navigator by clicking the arrow circle icon.
That's it!
For more detailed info, check the MySQL Workbench Manual: 6.5.2 SQL Data Export and Import Wizard
Upvotes: 1
Reputation: 133
For MySQL Workbench 6.1: in the home window click on the server instance(connection)/ or create a new one. In the thus opened 'connection' tab click on 'server' -> 'data import'. The rest of the steps remain as in Vishy's answer.
Upvotes: 9
Reputation: 1362
Hope it helps.
---Edited answer---
Regarding selection of the schema. MySQL Workbench (5.2.47 CE Rev1039) does not yet support exporting to the user defined schema. It will create only the schema for which you exported the .sql... In 5.2.47 we see "New" target schema. But it does not work. I use MySQL Administrator (the old pre-Oracle MySQL Admin beauty) for my work for backup/restore. You can still download it from Googled trustable sources (search MySQL Administrator 1.2.17).
Upvotes: 88