r/Database • u/Gaspucci22 • Sep 19 '26
How to convert from microsoft sql to mysql?
I need urgent help. I have a database that i created in Microsoft sql server express, but my professor has problems opening it and request that i convert it in mysql. I'm currently trying to do it but to no avail. I need help please
7
Upvotes
3
u/Gaspucci22 Sep 19 '26
Solved it- i followed this tutorial for the solution (https://youtu.be/VthWurnJ3Hk) and it worked like a charm but i had a deeper problem, which was that didn't even have a mysql80 connection and xampp was acting up not wanting to start up mysql in the control panel, which i solved by stopping the service, clearing the port of it, had some redundant master and relay files in xampp/data folder which i moved in a backup folder and it works now, took me like hour and a half.
I was doing this for my academic final exam. Its a web application for records of work engagement of employees
5
u/admik Sep 19 '26
Consider rewriting the database in MySQL instead of trying to migrate.
There is a lot of data type conversions, statement changes, IDs, etc. that needs to be handled.
Sqlglot that someone else posted looks interesting.
3
u/KeeperOfAngelsNorth Sep 19 '26
The other advice is good but beware of PIVOT. Only mssql and oracle support the operation directly. There will be a lot of contortions to construct similar effects for MySQL.
2
u/LetUsSpeakFreely Sep 19 '26
Since this is a school project, just rebuild the schema in MySQL, export the data from SQL Server into CSV format, then import it into MySQL.
2
u/Leorisar Sep 19 '26
use sqlglot library, it can convert from one sql dialect to another
https://sqlglot.com/sqlglot.html
1
u/Few_Committee_6790 Sep 19 '26
Use the tools that you have to create the script(s) to create the MSSQL database then try to run it against a mysql instance. Fix the errors and they come up rinse and repeat until done. Do the same for the data . tonquick.and easy but.consider it way to.learn the details of both DBMS systems and their tools
1
u/SnooRegrets5754 Sep 19 '26
Claude
1
u/EmmoKitten Sep 21 '26
don't panic))) your professor can't open it because mssql saves data in its own proprietary formats (.mdf/.ldf) that mysql simply cannot read. you can't just send him the file. you have to export the actual structure and data. the easiest way to do this without writing massive script:
get MySQL Workbench (it's free)
connect it to your local mssql express and your local mysql (or mariadb, your professor won't notice the difference for a class project)
run the Database Migration Wizard inside it. it connects to mssql, reads the tables, and creates them in mysql for you.
or DBeaver is another free tool for this
0
u/xpgmi Sep 19 '26
The question can be more specific, but I think you want to migrate the "create table" statements from tsql to mysql and not the data contained in the database itself.
Just use ssms, right click the dB, generate script, once you got the tsql, paste to any online ai chat like gemini, grok, chatgpt ask it to convert to mysql sql, then run that script to mysql.
0
u/Aggressive_Ad_5454 Sep 19 '26
Export your database from SQL Server as a .sql file. This says how: https://stackoverflow.com/questions/3240978/sql-server-how-do-i-export-entire-database
Then import it into MySQL. You'll have to edit the table definitions in the .sql file to make them compatible with MySQL. You'll need a running MySQL instance to get the import operation to work.
I think you can use DBeaver or HeidiSQL to do the import. You may also be able to use one of those tools to do the export operation from SQL Server.
If this is for submission to a professor, you might consider importing to SQLite instead. You can just send the .sqlite file to the prof.
0
u/thetwoweeks Sep 19 '26 •
DBeaver. Best way. Create connections to your MSSQL and MySQL databases and copy the data over.