Migration from SQL Server to MySQL - mysql

I need to migrate data from SQL Server 2000 to MySQL. Currently I am using MySQL workbench. Can any one tell how to do this?

If you are searching for a tool MySQL has a tool called "MySQL Migration Toolkit" that can be used to migrate the data from SQL to mysql. But the first thing as mentioned above is to do a backup. The next thing to check would be whether there are any datatypes that cannot be converted?

Exactly, what have you tried? You can quickly migrate data from MSSQL to MySQL if they are in any of the following data file formats:
Paradox (.db)
DBase (.dbf)
Delimited Text (.txt)
Excel (.xls)
XML (.xml)
MS Access Database (.mdb)
ODBC
If its a one-to-one, exact same database architecture on both the new and the old servers, you might want to try using database tools meant to make this an easier process for GUI based administrators. Just go to download.com and find some software that may assist you in that migration, Navicat is a good one. The most important thing is to always BACK IT UP! BACK IT UP! BACK IT UP! Never do anything without mirroring drives and doing whatever it takes to make sure if you don't destroy any data, but if you do you'll have backup copies of it. Also how fast your machines are will be a sizable factor when it comes to migrating very large databases.
All in all you have many options to choose from, yet the most important thing is to back it up! Can't stress that enough, yeah it might seem like meaningless extra work especially on humongous database systems, but trust me, its better to be safe than sorry. Also, I always like rebooting machines prior to making database changes to them, cutting off any connection to the outside world or any processes depending or updating its data. Turning off the ODBC will do much of that for you on Windows as well, but as always better safe than sorry. Many a corruption can be avoided by simply booting the machine and having all data in memory finalized on the active database, before backing it up or appending to it.

Check out etlalchemy. It is a free, open-sourced Python tool capable of migrating between any of the following SQL databases: PostgreSQL, MySQL, Oracle, SQL Server, and SQLite.
To install: pip install etlalchemy
To run:
from etlalchemy import ETLAlchemySource, ETLAlchemyTarget
# Migrate from SQL Server onto MySQL
src = ETLAlchemySource("mssql+pyodbc://user:passwd#DSN_NAME")
tgt = ETLAlchemyTarget("mysql://user:passwd#hostname/dbname",
drop_database=True)
tgt.addSource(src)
tgt.migrate()

Related

Database during release and developing

I am new to Database programming and there is some general questions that I would like to ask. I created the schema in my localhost using mySQL and linked to eclipse. There are some problems that I do not know how to approach.
One of my friends would like to help to develop at his personal machine, but he could not link to my database server. So one way is to copy the schema to his mySQL and change the connection string, are there any better ways?
If I would to release the project and run it on different machines, will it affect the databases operation since the schema resides in my local server.
Is there ways to just like attach the database inside the project since it is a local database and I am not accessing it from any other programs.
Sorry if my questions sound very stupid. I am really new.
Your approach of running local test MySQL instance for every developer sounds fine.
However, if your application never needs any data shared (essentially database is always local as you stated), then you should ask yourself if MySQL really an appropriate solution for your application. I think SQLite is a better choice in that situation - it is likely to work faster than MySQL for local access, and it has essentially zero setup - no database daemon to run or anything like that which greatly simplifies application install.
Granted, SQLite has its limits, but I often use SQLite for my projects, and only if they grow large, I might migrate them to MySQL or PostgreSQL if task requires it.
Typical signs that SQLite may not cut it:
Many clients (10+) need to access database for writing
Total database size is very large - more than 10GB total

Will exporting a database using MySQL Workbench cause downtime on server?

I am using Workbench to export a database stored on my hoting providers server, will the server experience any downtime whilst I am exporting the data?
The only reason I ask is because when I back up my local SQL database my server needs to be switched offline for it to work.
All comments will be much appreciated.
Ben
No it will not cause a downtime, unless your server has really low resources (in which case you should find a better hosting). Seriously though, nothing bad will happen.
Also I can hardly imagine why you need to disable your localhost for backup... Workbench uses mysqldump for exports and this in turn needs MySQL to be online...

Delvering a modified database from the local env to the production one

I'm working with MySQL databases.
To simplify the problem, let's say I have two environments : the local one (development) and the remote one (production mode).
In the database, I have some tables that contain configuration data.
How can I automate cleanly the delivery from the development mode to the production mode when I modify the database schema and the configuration tables content ?
For instance, I dot it manually by doing a diff between the local and remote databases. But, I find that method not so clean and I believe there is good practice allowing that.
This might be helpful in cases where you have multiple environments and multiple developers making schema changes very often and using php.. https://github.com/davejkiger/mysql-php-migrations
Introduce parameter "version" for your database. This version should be written somewhere in your code and somewhere in your database. Your code will work with database only if they have equal versions
Create a wrapper around your MySQL connection. This wrapper should check versions and if versions are not compatible, it should start upgrade.
"Upgrade" is a process of sequential applying the list of *.sql files with SQL commands, which will move your database from one state to another. It can be schema changes or data manipulation commands.
When you do something with database, do it only through adding new *.sql file and incrementing version.
As a result, when you deploy your database from development enviroment to production, your database will be upgraded automatically in the same way as it was upgraded during development.
I've seen LiquiBase http://www.liquibase.org/ a lot in Java environments.
In most of my projects I use sqlalchemy(a Python tool to manage db plus an ORM). If you have some experience(little more than beginner) with Python I highly recommend using it.
You can check this tool with a little help of that. This is also very useful for migrating your db to other rdbms(for example mysql to postgres or oracle).

I'm trying to migrate SQL SERVER Express to MySQL

I have a somewhat small database in SQL Server Express 2005 that I really need to migrate over to a MySQL install on my hosting service (Dreamhost). After reading for a couple days, everything pointed to the MySQL Migration Toolkit, which is unfortunately EOL. I was able to find an archive and install it on my server running Sql Server. I set the source database, and set my Dreamhost MySQL as the destination. For whatever reason I get tons of permission errors trying to migrate although the user I'm connecting to MySQL as full permissions (working with dreamhost on this).
Is there a better way to do this? I've heard that I should use some third party tools, (like dbtools) and then I heard NOT to use third party tools.
Like I said the database is small, with a few views, a few functions, and a few stored procs, which I can manually move over if needed.
What are my options? Thank you!
Export your SQL Server database to a downloadable package (SSIS?)
Install SQL Server Express locally.
Install MySQL locally.
Run the Migration Toolkit locally.
Dump the MySQL database
Upload and run the Dump file # DreamHost (via phpMyAdmin if possible).
For such a small database you may spend more time trying to get a 3rd party tool to work for your situation than it would take you to just move the stuff manually. If you used standard SQL and little to nothing proprietary to SQL Server, creating the objects manually in MySQL should be easy enough... you just have to be aware of the slight syntax differences between the two platforms. Once the structures are created, generating insert statements to populate the data should also be trivial.

Remote backup of MySQL database

Our Java server application logs data to a SQL database, which may or may not be on the same machine. Currently we use MS SQL Server, and we're now porting to MySQL. A user configures database backup parameters on our app server, e.g. time of day to run a backup, and the app server executes SQL Server's BACKUP DATABASE command at the appropriate time, via a sproc. It does incremental backups daily and full backups weekly.
MySQL lacks an equivalent feature to tell the database from a client connection to back itself up. Options we're considering are:
Create a UDF to shell out to mysqldump (or copy database files), which can be called from our app server via a sproc. Essentially we'd be implementing a version of BACKUP DATABASE for MySQL.
Create a service to run on the MySQL box that can get the backup settings from the app server and run mysqldump (or file copy) locally.
Create a backup sproc to mimic mysqldump, e.g. SHOW CREATE TABLES and SELECT INTO OUTFILE for each table.
Setting up a cron job, Perl script, third-party app or other tricks that'd work great in a data center aren't preferred; this is a shrink-wrap package that needs to be pretty robust and hands off.
Database sizes can range from roughly 10MB to 10GB.
I'm aware of the binary logs for the incremental piece. I figure the general solution will probably apply to them as well, if we decide to use them.
This is all on Windows 2003 32-bit or 2008R2 64-bit, MySQL 5.1.
The UDF option seems the best to me. The UDF Repository (http://www.mysqludf.org/) has mysqludf_sys, which may be all we need, but I thought I'd ask for opinions since after extensive googling it doesn't seem like others have reached the same conclusion, or maybe our needs are just out of the ordinary. Our app is the only thing in MySQL, so I'm not worried about other users having access to our UDF.
Any solutions I'm overlooking? Any experience with using UDFs in such a way?
Thanks,
Eric
For this an other reasons we decided to collocate our application with the database, so this problem became moot.