Your SQL database connection details. We’ll use MySQL in this tutorial but SQL Server, PostgreSQL, and Oracle are also supported.
Access to SQL Migration. Studio 3T offers a free 30-day trial here.
To illustrate a simple SQL database import, we’ll use the publicly available world database which contains three tables:
We’ll import each SQL table to a MongoDB collection, which means we should have three new collections in our target database.
Click on SQL Migration > SQL -> MongoDB Migration in the toolbar.
Click on Click here to connect to a server to open SQL Connection Manager.
If you’ve already saved a connection, choose your source SQL connection from the list (we’ll use sql-database).
To create a new SQL connection, click on New Connection, enter the connection details under the Server and SSH tabs, and click Save.
Like Step 2, click on Click here to connect to a server to choose an existing MongoDB connection or to create a new one.
Here we’ll choose mongodb as our target connection. This is where the three collections will be created.
Studio 3T calls them “import units”, but an import unit simply means the SQL source table.
Click on Add import units.
We’ll choose the three world tables –
countrylanguage – to create a collection for each.
By default, Studio 3T will map each table to a collection with the same name.
Click OK. All three tables should appear in the Overview.
It’s time to run the SQL import. Click on Run Migration.
Track your import in the Operations window on the bottom-left hand side.
Double-check that the world database was imported in the Connection Tree (top-left).
And finally, double-click on a collection (like
country, highlighted above) to check if the data looks correct (and it does!)
The world database is quite simple – requiring no one-to-one or one-to-many table relationships – so the default mappings are sufficient for this import.
Note, however, that SQL Migration lets you fully control these mappings. Learn how to merge multiple SQL tables into one MongoDB collection to find out how you can use SQL Migration to do more complex imports.