In this tutorial, we’ll show you how to export your MongoDB data directly to a live SQL database using Studio 3T and our new MongoDB to SQL Migration feature.
First things first
- Studio 3T: Make sure you have Studio 3T up and running.
- SQL database: Have your SQL connection details ready. I’ll be using SQL Server for this tutorial, but Studio 3T officially supports MySQL, PostgreSQL, and Oracle as well.
For our MongoDB to SQL migration, we’ll make use of the two datasets:
- Raleigh Durham Airport Weather History
- Air Traffic Passenger Statistics
1 – Open SQL Migration
Click on SQL Migration from the Global Toolbar then choose MongoDB → SQL Migration.
![](https://studio3t.com/wp-content/uploads/2020/11/1-1-1024x546.png)
2 – Choose the MongoDB source connection
Now we need to connect to our MongoDB server that holds the collections we wish to migrate.
To do this, click on Click here to connect to a server.
Now we have two options: connect to an existing MongoDB server or create a new connection, which first-time users will likely need to do.
To create a new MongoDB connection, click on New Connection.
![Create a new MongoDB Connection](https://studio3t.com/wp-content/uploads/2020/11/2-connection-manager.png)
Enter the relevant details in the Server, Authentication, SSL, SSH Tunnel, Proxy and Advanced tabs.
![Create a new MongoDB Connection](https://studio3t.com/wp-content/uploads/2020/11/3-1.png)
Click Save, then Connect.
You can then simply choose this connection from the list for your next migration.
![Select the MongoDB Connection](https://studio3t.com/wp-content/uploads/2020/11/4-1-1024x546.png)
3 – Choose your SQL target connection or directory
The next step is to choose our target SQL database.
Studio 3T lets us directly connect to a SQL server and immediately migrate our data, or save this migration as a SQL file path that can be run later at our convenience.
If SQL target = Server
![](https://studio3t.com/wp-content/uploads/2020/11/5-video_masked_compressed-1.gif)
Click on Click here to connect to a server.
Similar to Step 2, this will open up the SQL Connection Manager.
Create a new SQL connection by clicking on New Connection. Fill out the Server and SSH Tunnel tabs with the details needed.
Click Save. Then click OK. You can then simply choose the saved connection for future migrations.
If SQL target = Directory
If you choose to save to a SQL file path, Studio 3T will let you choose the location of the statement file as well as the database type.
4 – Add export units
Now that we’ve successfully connected to both our MongoDB and SQL servers, it’s time to choose our data.
Click on Add export units. Each export unit corresponds to one single export of a source collection.
Here we’re going to choose the collections we wish to migrate to MySQL, which are:
- Raleigh Durham Airport Weather History
- Air Traffic Passenger Statistics
Click OK.
![Studio 3T generates a SQL table preview of the data.](https://studio3t.com/wp-content/uploads/2020/11/6-1-1024x546.png)
Upon selecting the databases, Studio 3T will generate a SQL Table Preview of your data. Here we can see the SQL table(s) that will be made from our MongoDB collections.
5 – Run the export
Is the SQL Table Preview looking good? Then it’s time to run the export by clicking on Run Migration in the top toolbar.
Track the export in the Operations window which you’ll find in the bottom left hand corner of Studio 3T.
![Click Run Migration to begin the migration](https://studio3t.com/wp-content/uploads/2020/11/7-export-run-migration-1024x546.png)
Once the export is complete, open your SQL database and hit refresh to see your newly imported data.
Video tutorial
Next steps
Find helpful tutorials on how to query SQL with MongoDB, migrate between the two databases, and more.