I'm trying to duplicate my mysql tables for hsqldb in order to run some unit tests in my JPA / Hibernate project.
There are only two tables at the moment, but I can't get neither created in hsqldb. I used the example code from Spring documentation to run a schema.sql script before the test cases:
db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
But it always fails with "Unexpected token" exceptions with the token ranging from "DATABASE" to "(".
Is there a straight forward way of converting the mysql dump into something that hsqldb would understand? Or should I populate the test database some other way?
I worked many years with HSQL and MySQL database and there's no tool that I know that converts a MySQL dump into a hsqldb script. I see two solutions here:
Make a script or a program that converts MySQL dumps to hsqldb script. You can follow the list of steps to do in this post:
How to load mysql dump to hsqldb database?
Use BOTH responses
https://stackoverflow.com/a/3813164/891479
and
https://stackoverflow.com/a/7791340/891479
as the first one is not complete.
Make a small program that connects to both DB, load your MySQL tables into objects and fill your hsqldb.
We always used the first solution, it's probably the easiest one.
Related
We have a fairly large MySQL database with more than a million rows of data with every possible data type.
It is a part of a custom MVC application built more than 5 years ago. We have to migrate it now.
There are a large number of queries and insert statements which we want to replace with JSON based web services so that it can be used with every kind of app/device etc.
A large number of PHP functions have been fused with display logic making it tricky. Also there are also a few MySQL functions in the bundle.
Please share tips/suggestions/tools that would be useful for this migration.
There are some tools which I can suggest you to convert your Mysql database to Pgsql one here is some of them:
pgloader
PostgreSQL Data Wizard
pgloader
dataPro
And based on my experience, I suggest you pgloader to load data from MySQL, SQLite, MS SQL Server, dBase files, CSV files and fixed-width data files, and more. Released under The PostgreSQL Licence..
I need a working tool for migrate DDL objects and data tables from MS SQL Server to MySQL. I checkout Database Migration Wizard in MySQLWorkBench 6.3,i have also tested with Ispirer tool (not free) and i can migrate only tables and data in tables but not views, store procedures and functions (maybe trigger not)..
In this MySQLWorkbench tools page : https://dev.mysql.com/doc/workbench/en/wb-migration-overview.html i found
"d.View objects are copied, and commented out if the source is not MySQL.
e.Stored Procedure and Function objects are copied, and commented out if the source is not MySQL."
So, i'm confused about why copy them and comment-out and not try to convert syntax? we know that database source is MSSQL so the syntax is different from mysql? I think it's impossible write mysql objects in MSSQL Server..no?
Thanks
Roby
Yes, the syntax is different in MySQL. The conversion process is too complicated to do it automatically, however we gave the possibility to convert it manually. So if you want migrate those views/procedures, you must uncomment it and rewrite to MySQL compatible sql.
I'm considering a MySQL to Postgresql migration for my web application, but I'm having a really hard time converting my existing MySQL database to Postgresql.
I tried :
mysldump with --compatible=postgresql
migration wizard from EnterpriseDB
Postgresql Data Wizard from EMS
DBConvert from DMSoft
and NONE of the above programs do a good job converting my database!
I saw some Perl and Python scripts for converting mysql to postgresql, but I can't figure out how to use them....(I installed ActivePerl and don't understand what I'm supposed to do next to run that script!)
I use Auto Increment fields (as a primary key) all the time, and these are just ignored... I understand that Postgresql does auto-increments in another way (with sequences), but it can't be THAT hard for MIGRATION software to implement that, or is it?
Did anybody have better luck converting a MySQL database with auto-increments as primary keys?
I know this is probably not the answer you are looking for, but: I don't believe in "automated" migration tools.
Take your existing SQL Scripts that create your database schema, do a search and replace for the necessary data types (autonumber maps to serial which does all the sequence handling automagically for you), remove all the "engine=" stuff and then run the new script against Postgres.
Dump the old database into flat files and import them into the target.
I have done this several times with sample databases that were intended for MySQL and it really doesn't take that long.
Probably just as long as trying all the different "automated" tools.
Why not use an ETL Tool? you dont have to worry about dumps or stuff like that.
I have migrated to PostgresSQL and MySQL and have had no problems with the auto increment fields.
You just need to know the connection credentials and thats it. I personally use Pentaho ( it's open source ).
Download Pentaho ETL from http://kettle.pentaho.org/
Unzip and run Pentaho (using .bat file spoon.bat)
Create a new Job:
Create DB connection for source data base (PostgreSQL) - using menu: Tools→Wizard→Create DataBase Connection (F3) Create DB connection for destination data base (Mysql) - using technique described above.
Run the Wizard: Tools → Wizard → Copy Tables (Ctrl-F10).
Select source (left dialog panel), and destination (left dialog panel). Click Finish.
The Job will be generated - Run the job.
If you need any help let me know.
Even when you familiar with all "PostgreSQL gotchas", doing every step by hand may take a lot of time, especially when your db is "big".
Try some other scripts/tools.
I know this is an old question but I just ran into the same problem migrating from MySQL to Postgres. After trying several migration tools out the very best one I could find, which will migrate your database structure as cleanly as possible, was Pgloader https://github.com/dimitri/pgloader/ it will take care of changing the Auto Increment to Postgres sequences no problem and it's super fast.
We need to redo a database in MySQL that has been already done on Informix, is there a way to migrate not only the schema, but the stored procedures as well?
Thanks.
We have a client whom we built a web application that uses an Informix database. Now the client wants to be able to implement the same software but on multiple closed networks (like 20). Doing this using Informix would be very expensive (20 licences X_X).
So the best approach is to redo the database on something like MySQL.
The application was done using Flex, .Net (using ODBC) and Informix.
I have done a similar thing, but I migrated Informix database to PostgreSQL. At first I dbexported the whole database, so the whole data and schema info was in text. Then I wrote some Python programs that translated schema, for example Informix DATETIME YEAR TO SECOND must be converted to timestamp with time zone.
When all CREATE TABLE/INDEX etc worked then I translated .unl files to PostgreSQL COPY commands. You should search how to do bulk load in MySQL, or convert those files to INSERT commands.
After that I started converting stored procedures. While PostgreSQL PL/pgSQL and Informix SPL are very different this part was the hardest and I was able to automatically convert only function "prototypes". Functions body had to be converted manually.
If you completed this you will have to check if your application work well with a new SQL implementation.
I have encountered a problem where I need to copy only data from a Postgresql database to Mysql database. I already have the Mysql database with empty tables. By using PGAdmin I got a backup (data only, without database schema). I tried using PSQL tool but it keeps giving segmentation fault which I couldn't fix at the moment. I am using Ubuntu. Any simple help with a guide will be highly appreciated to copy data.
Use postgres COPY, and MySQL LOAD DATA INFILE.
psql will crash because of out-of-memory if you try to display a few millions of rows because it fetches all the data beforehand to determine the column widths for a prettier display. If you intend to use psql to fetch lots of data, disable this.
You could try:
http://www.lightbox.ca/pg2mysql.php
It looks like you might be trying to load data into mysql with the postgres client tool. Use the mysql client tools to manipulate data in the mysql server.
mysql client programs
How can you move data into MySQL if you have errors reading from PSQL?
Fix the error, then ask this question.