Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

This question already has an answer here:

I have two Microsoft SQL Server database files named "xxx.mdf" & "xxx.ldf" and I want to import that database into MySQL so I can run queries against it using phpMyAdmin. How would I go about doing this?

share|improve this question

marked as duplicate by Jon Seigel, Marian, Max Vernon, Mark Storey-Smith, Shawn Melton Apr 7 '13 at 23:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Do you already have SQL Server 2008 installed? If so, has the database (xxx.mdf) been attached to the SQL Server instance so you can see it in SQL Server Management Studio? –  Gord Thompson Apr 7 '13 at 13:48
    
No sir i dnt have SQL server installed in my pc..If you could provide me the link ..... The OS version of my pc is Windows 8 (64 bit ) .So please provide me the accurate download link..It will be very helpful for me –  Nafiz Apr 7 '13 at 13:57
    
Check this solutions also you can download and install sql server 2008 Express and create sql files from your current files –  Ashian Apr 7 '13 at 14:49

2 Answers 2

The first thing to note is that an .sql file is not a MySQL database. It is a script file containing SQL statements. You would run such a script against the database platform for which it was written (using the SQL dialect for a specific SQL database engine) to create the actual database.

Assuming that you are planning to do this all on a desktop machine with no software already installed, here is an overview of the steps to accomplish what you stated in your question. To describe every step in detail would make for a very long answer, so take this as a "roadmap" and start working through the steps. If you run into any particular difficulties that create a new question for that specific issue.

(Also, see the "Notes" at the bottom for a couple of possible alternatives.)

Install Microsoft SQL Server

If you are reasonably certain that the database in question is no larger that 10 GB and uses no Enterprise-level features (thanks, Jon!) then download SQL Server 2008 Express from here (thanks, Ashian!) and install it. Otherwise, download and install the (180-day trial) SQL Server Enterprise Evaluation Edition.

Attach the SQL Server database

Once SQL Server is installed, you need to "Attach" the existing database (.mdf/.ldf files) to the instance of SQL Server that you just created.

Install MySQL Server

To create and manipulate a MySQL database you need to have the MySQL Server software installed.

Install Internet Information Services (IIS)

phpMyAdmin is a web-based administration tool for MySQL, so it needs a web server environment in which to operate.

Install PHP

phpMyAdmin runs under PHP, so your IIS install must have that available, too.

Install phpMyAdmin

You need to install it if you're going to use it.

Install MySQL Workbench

MySQL Workbench will do the actual conversion from Microsoft SQL Server to MySQL.

Notes:

  1. Of course, once you have SQL Server installed and the database attached, you could always "make multiple quer[ies]" against the database in SQL Server itself.

  2. If the database really needs to be in MySQL (e.g., if you already have MySQL queries written or provided to you) but you only need to query the database locally, then a tool like HeidiSQL might allow you to avoid installing IIS, PHP, and phpMyAdmin. In fact, HeidiSQL might be able to do the conversion for you (e.g., by doing an export from SQL Server and an import into MySQL), in which case you could use it instead of MySQL Workbench.

share|improve this answer
2  
I would actually recommend installing SQL Server Enterprise Evaluation Edition (free 180-day trial) for a couple reasons: (a) this is only temporary (I assume), and (b) although it's unlikely, if there are any Enterprise Edition features persisted in the database (such as table partitioning), Express will refuse to attach, thus wasting valuable time. If a longer-term solution is necessary, I would buy a copy of Developer Edition (~US$50), which includes all features found in Enterprise but isn't licensed to be used in production. –  Jon Seigel Apr 7 '13 at 17:13
    
@JonSeigel Thanks for your insights! I will update my answer. –  Gord Thompson Apr 7 '13 at 17:16

my fav app for manage my databases is http://www.heidisql.com/

enter image description here

and you can also Exporting databases as SQL Query then run query in mysql.

share|improve this answer
1  
Have you tried this before? Do you know from experience that T-SQL scripts created by Microsoft SQL Server will work when run against MySQL? (I don't know because I've never actually tried it, but I really doubt that it will work.) –  Gord Thompson Apr 7 '13 at 15:37
    
yes, but with a editor and with Find-Replace you can make your mysql query.. –  mehdi Apr 7 '13 at 15:51
    
Is it possible to import mdf and export sql or csv with this kit HeidiSQL.??? –  Nafiz Apr 7 '13 at 16:50
    
Is it possible to import mdf and export sql or csv with this kit HeidiSQL.???If possible then please describe the procedure . –  Nafiz Apr 7 '13 at 16:56
    
so you can attach your .mdf file to sql server then open it with HeidiSQL and export to a mysql db directly –  mehdi Apr 7 '13 at 17:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.