Yeah. Its been a while since I posted last. So what I wanted to tell you guys today is how to migrate data from My SQL database to a SQL Server. Well when you google it you may fine various ways to do that. Most of them require 3rd party software like ODBC Data Source Administrator or SSMA (SQL Server Migration Assistant). Well if you were someone like me then of course you will export the database from My SQL Server to a .sql file and then try to insert data manually. So this post is for the guys who have tried it all and nothing worked out.
What I will be using in this post is SQL Server Import and Export Wizard. First question that comes to any one's mind is where can I find this? Is this another 3rd party software that I have to download and install in my PC. Well this is a inbuilt function in SQL Server. For this post I will be using SQL Server 2014 for the demo. Let get to it then.
This is how its done. First you need to install SQL Server 2014 and you need to have a remote or a local My SQL data base which you are targeting to migrate data from. After installing SQL Server you have to create a database so that you can migrate data from My SQL database.
When you open the SQL Server you will get a window like this. Guys don't be concerned about the query in this pic. I took this photo from google. On to your left side you have the Object Explorer window opened. In that window we have the following main folders.
In these folders simply right click on the database folder and you will have a menu. There click on the new database option then you will get a window like this.
Give a name to the database and press OK. There you go, now you have a brand new database. For this post the I have created a database named test. Once you have your database ready go into the database folder and you will see your database. Right click on it and you will get a menu. In that menu at the bottom you will have a bar named Tasks. When you place your mouse cursor on that tab you will get another menu. At the bottom of this menu you will see 2 options. They are
- Import Data
- Export Data
If you don't want this this introduction window to appear every time you open this, you can check the check box near the buttons at the footer of the window. If you like this window just like I do the simply press the next button. Then you will have a window like this.
In the data source tab select .Net Framework Data Provider for MySQL from the drop down list. Then you need to add some information which will allow this application to access your My SQL database. Now scroll down to Connection and give the following details.
In here you need to give the information about your My SQL database. You need to give the database name, port number and the server. Finding the port is really easy.just type "Show Global Variables Like 'port' ". If you are using your local server like WAMP Server of XAMMP Server you can give local host just like I have done. If not you need to give the specific server name.
Then you need to give the authentication credentials to access the My SQL database. To do so you need to scroll to the bottom of the window where you will find Security section.
Your default user name is root and I have kept that here. Even though I have used the default one, if you have a different user name, make sure to use that user name as User Id. I would always recommend having a password for your database. So I have entered the password as well. Then click Next. If every thing goes well then you will have an window just like the previous one but with out data. The first window was for our source and the second one is for our destination. Since we need to import the data to SQL Server we need to select SQL Server Native Client form the drop down menu where we selected the .Net Framework Data Provider for MySQL.
Then you will have a bit different window.
It will automatically get the database name if every thing goes well. Then click next.
In this you need to right a query to get data form the table in your My SQL database. Both the table and the database I have named as the test. You need to write a select query for the table in the My SQL database. Here my query is "Select * from test"
Then click next. If every thing goes correctly then you will get the next window.
If you want to edit the mapping you can do that by clicking the Edit mapping button. Then click next. You will get a window named Conversion types with out conversion checking. Click next button. Then you will get the following window. keep the automatically checked Run Immediately check box and then click next. At the end you will have the following window and then click Finish.
When you click finish, then the query will be executed and data from My SQL table would be imported to a table name Query (The Default table) in your SQL Server database.
Now all you have to do is check whether the data is being migrated to your SQL Server. Go to the SQL Server and navigate to your relevant database and see. You will have all the data from the specific table in My SQL database being imported to your database.
That is how data migration from My SQL database to SQL Server is done. So Until the post I'm out of here. Thank you for reading this. Buy.
Tharindu Senanayake



