How to import and export MySQL databases

These notes will walk you through the correct method for importing and exporting databases in MySQL.

Getting started

The first thing you will need to do is to configure the MySQL administrative tools to give you access to your databases.

Launch the MySQL Workbench application. In the home window you see after startup you should see a section labeled MySQL Connections'. There should be a button in that section for your local instance of MySQL. Click that button to access options for your local server.

If the MySQL server you have installed on your machine does not show up automatically in the connections list, click the + button and fill in the fields in the resulting dialogs to establish a connection to the MySQL server running on localhost.

Importing a database

Before importing a database you will need to set up the empty database. To make a new database, click the Schemas tab in the left pane and then right click in the 'Schemas' pane. Select the option 'Create Schema...' from the popup menu and type a name for the database you want to create.

To import a database from a folder you have dumped or I have provided on the web site, start by clicking on the 'Administration' tab in the Navigator, then click on the Data Import/Restore link, In the Data Import window make sure that the 'Import from Disk' tab is active.

Click the '...' button next to the Folder Path field to open a dialog to select the folder you want to import from. Once you do that the database you want to import should appear in the import list at the bottom of the window. You can click on the database to confirm that all of the tables you need to import are present. Click 'Start Import' to import the database.

Note that the database you created in the first step has to have the same name as the database you are about to import. If the names do not match, right-click on your database in the Schemas section and select the option 'Alter Schema'. Type the correct name for the database and then click the apply button.

Exporting a database

Click the Data Export link in the Navigator to access the database export screen.

To export a database, click the checkbox next to the database you want to export and edit the path information under the 'Export to Dump Project Folder' radio button. Note that you should have a folder already prepared to receive the dump file. Click the 'Start Export' button to run the database export.