Command for exporting MS Access Database to Mysql - mysql

Is there any command to export Access Database table to MySQL using command line.
i know we can do it manually. but i want to do it automatic on specific schedule. so if any command will there than we can do it using command line.
Once we done with it we can create batch file and we schedule it.
Can any one suggest me which one is best.
thank you.

You can use Data Import feature (MS Access format) in dbForge Studio. Command line is supported for Data Import. Just create import template file and use it in your schedule task. Try trial version).

Related

How to migrate daily data from Oracle table to MySQL table using Shell script?

I needed to insert data to a MySQL table. The data usually comes from the Oracle database by a SQL file which has some query to get data from Oracle database table.
So i needed to automate this process on a daily basis using Shell script. So it will run the SQL file (Oracle) and get data. The data has to be moved to a specific MySQL table.
So the operation like,
Connecting to Oracle server.
Executing SQL in that server.
Move collected data to the MySQL table.
I want to run that operation as a cron on daily basis.
I am working on LAMPP environment.
Here are my questions,
Is there any standard tools available to do that?
Can we achieve this using shell script? If so, Please suggest me the steps.
Or It would be great if you suggest me your own optimized way.
Thanks,
Raja.
You can achieve this using a cron job,
Write a sql file which exports a data from Oracle DB i.e. sql file containing export table command with appropriate where clause
Write a sql file which imports data into Mysql DB i.e. similar import file command in Mysql
Write a shell file which run both these sql files and verifies the data in Mysql table
Schedule a cron job to run this shell script daily at a specific hr.
Please check import/export file formats on Oracle and Mysql which can be different as one is freeware and other is commercial. If there are differences then you will need some data/file modification otherwise this should be enough.

How to convert .db file to .sql file

I have mydatabase.db file and I want it to be conveted to mydatabase.sql file.
How to do this?. Thank you.
Is there any sqlite command?. or any software to convert this, or any mysql command?.
There is simple sqlite command:
sqlite3 database.sqlite3 .dump >> database.sql
Note the dot before "dump". This is special command to sqlite3 cli client eg. dot-commands.
For Ubuntu, sqlite3 can be installed by:
apt-get install sqlite3
You can try Valentina Studio (license is free, crashes far less than MesaSQLite)
Steps:
Open the .db file in Valentina Studio
Select a table in schema editor
Right/Alternate click the table name
Generate SQL
Show Create
And in a new editor tab that appears, you will have a sql create statement you can use for your mysql server. Note: Depending on the complexity of your table you may need to apply corrected syntax for it to work in mysql.
If you need to copy the rows contained in your selected table you can create a dump (from right click on table) and then import.
DB Browser for SQLite http://sqlitebrowser.org it's free and unlike Valentina Studio requires no registration and does not have a 10 minute timeout period.
To use just open .db file then from the file menu select 'Export' -> 'Database to SQL file..'

Downgrade mdf file from 661 to 655

I created and database in sql server 2008. I took the mdf and ldf files to Visual Studio 2010 project and tried to connect to that db with entity-framework. and got the following message:
I cannot reinstall or upgrade the software on the specific computer.
So is there any way to downgrade the version of the mdf and ldf files?
No, you cannot downgrade, you will need to move the schema and data another way if you can't install the right version. This recent question is essentially the same:
Failure attaching SQL Server 2008 database to SQL Server 2005
Essentially you can use the Generate Scripts tool or the Export Data wizard to get your destination database to look like the source. You will not be able attach your MDF file.
And this blog post shows some 3rd party tools that can help with this:
http://bertrandaaron.wordpress.com/2012/04/20/re-blog-the-cost-of-reinventing-the-wheel/
No, you need to install the same or newer version of SqlServer.
There is no known way to downgrade an MDF file.
Links
http://blog.sqlauthority.com/2008/10/16/sql-server-downgrade-database-to-previous-version/
Perhaps, if you have access to the SqlServer 2008, you could use the command
"Tasks" -> "Create Scripts" to start the wizard to create a script with schema and data.
On the options page there is the button 'Advanced' where you can select the syntax version of SqlServer
The way that I found that worked was to export the database and stored procedures from the original database. Then upload them into the second database(second computer).
Firstly export the DB content (data) - I used SQL server export data wizard. on the database you wish to export from right click then choose tasks, then export data. Follow the instructions and save in whichever format is best for you - I used excel for the data.
then to export the stored procedures rightclick the database name again. choose tasks and this time choose generate scripts. again follow the instructions of the wizard.
To import the data simply go to the second computer and right click the database you wish to import the data into. again tasks > import data. Follow the instructions to import all of the data from the database.
Finally to import the stored procedures, I opened up a new stored procedures command and dragged and dropped the script file that I had previously saved them in and dropped it into this window. The new stored procedure window filled with the entire list of my stored procedures.
Finally change the name of the database name that will be used by the SP ( if this is different from the original DB name). (This is the first line USE [DBName].
then simply execute and the SP's will be fully restored.
This has helped me get my entire database up and running again very quickly.
Hope this helps.
U can open it on another pic and then publish it to sql script with or without data then create database on target PC using sqlcmd or anything. Then run sql script...

Possible to patch a mysql sql file without using phpmyadmin?

If I have a cms, shopping cart, or some db based web script and lets say it has a database with like 50 tables
If I have a .sql file (call it patch.sql) that has a few ALTER commands and some UPDATE commands, I can goto phpmyadmin, import the patch.sql file and it will "apply" the changes to my db.
But lets say I export my db to a mydb.sql file first
Is there a way to "apply" the changes from "patch.sql" to "mydb.sql" without using a database?
I figured some command line like
mysql.exe merge patch.sql mydb.sql
or something but I didn't see anything like that.
Is phpmyadmin with a database the only way?
If your goal is to be able to later reimport mydb.sql and get the patched version of the database, then no, there are no tools to do that. patch.sql may has altered the structure of the database as well as the data itself based on your description. What you should do is apply the patch to your database, then export your db to a new .sql file.

How to import a SQL Server .bak file into MySQL?

The title is self explanatory. Is there a way of directly doing such kind of importing?
The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm
The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.
You will need to use SQL server to extract these. SQL Server Express is free and will do the job.
So, install SQL Server Express edition, and open the SQL Server Powershell. There execute sqlcmd -S <COMPUTERNAME>\SQLExpress (whilst logged in as administrator)
then issue the following command.
restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO
This will list the contents of the backup - what you need is the first fields that tell you the logical names - one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM disk='c:\temp\mydbName-2009-09-29-v10.bak'
WITH
MOVE 'mydbName' TO 'c:\temp\mydbName_data.mdf',
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf';
GO
At this point you have extracted the database - then install Microsoft's "Sql Web Data Administrator". together with this export tool and you will have an SQL script that contains the database.
MySql have an application to import db from microsoft sql.
Steps:
Open MySql Workbench
Click on "Database Migration" (if it do not appear you have to install it from MySql update)
Follow the Migration Task List using the simple Wizard.
I did not manage to find a way to do it directly.
Instead I imported the bak file into SQL Server 2008 Express, and then used MySQL Migration Toolkit.
Worked like a charm!
In this problem, the answer is not updated in a timely. So it's happy to say that in 2020 Migrating to MsSQL into MySQL is that much easy. An online converter like RebaseData will do your job with one click. You can just upload your .bak file which is from MsSQL and convert it into .sql format which is readable to MySQL.
Additional note: This can not only convert your .bak files but also this site is for all types of Database migrations that you want.
Although my MySQL background is limited, I don't think you have much luck doing that. However, you should be able to migrate over all of your data by restoring the db to a MSSQL server, then creating a SSIS or DTS package to send your tables and data to the MySQL server.
hope this helps
I highly doubt it. You might want to use DTS/SSIS to do this as Levi says. One think that you might want to do is start the process without actually importing the data. Just do enough to get the basic table structures together. Then you are going to want to change around the resulting table structure, because whatever structure tat will likely be created will be shaky at best.
You might also have to take this a step further and create a staging area that takes in all the data first n a string (varchar) form. Then you can create a script that does validation and conversion to get it into the "real" database, because the two databases don't always work well together, especially when dealing with dates.
The method I used included part of Richard Harrison's method:
So, install SQL Server 2008 Express
edition,
This requires the download of the Web Platform Installer "wpilauncher_n.exe"
Once you have this installed click on the database selection ( you are also required to download Frameworks and Runtimes)
After instalation go to the windows command prompt and:
use sqlcmd -S \SQLExpress (whilst
logged in as administrator)
then issue the following command.
restore filelistonly from
disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO This will list the contents of the
backup - what you need is the first
fields that tell you the logical names
- one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM
disk='c:\temp\mydbName-2009-09-29-v10.bak' WITH MOVE 'mydbName' TO
'c:\temp\mydbName_data.mdf', MOVE
'mydbName_log' TO
'c:\temp\mydbName_data.ldf'; GO
I fired up Web Platform Installer and from the what's new tab I installed SQL Server Management Studio and browsed the db to make sure the data was there...
At that point i tried the tool included with MSSQL "SQL Import and Export Wizard" but the result of the csv dump only included the column names...
So instead I just exported results of queries like "select * from users" from the SQL Server Management Studio
SQL Server databases are very Microsoft proprietary. Two options I can think of are:
Dump the database in CSV, XML or similar format that you'd then load into MySQL.
Setup ODBC connection to MySQL and then using DTS transport the data. As Charles Graham has suggested, you may need to build the tables before doing this. But that's as easy as a cut and paste from SQL Enterprise Manager windows to the corresponding MySQL window.
For those attempting Richard's solution above, here are some additional information that might help navigate common errors:
1) When running restore filelistonly you may get Operating system error 5(Access is denied). If that's the case, open SQL Server Configuration Manager and change the login for SQLEXPRESS to a user that has local write privileges.
2) #"This will list the contents of the backup - what you need is the first fields that tell you the logical names" - if your file lists more than two headers you will need to also account for what to do with those files in the RESTORE DATABASE command. If you don't indicate what to do with files beyond the database and the log, the system will apparently try to use the attributes listed in the .bak file. Restoring a file from someone else's environment will produce a 'The path has invalid attributes. It needs to be a directory' (as the path in question doesn't exist on your machine).
Simply providing a MOVE statement resolves this problem.
In my case there was a third FTData type file. The MOVE command I added:
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf',
MOVE 'sysft_...' TO 'c:\temp\other';
in my case I actually had to make a new directory for the third file. Initially I tried to send it to the same folder as the .mdf file but that produced a 'failed to initialize correctly' error on the third FTData file when I executed the restore.
The .bak file from SQL Server is specific to that database dialect, and not compatible with MySQL.
Try using etlalchemy to migrate your SQL Server database into MySQL. It is an open-sourced tool that I created to facilitate easy migrations between different RDBMS's.
Quick installation and examples are provided here on the github page, and a more detailed explanation of the project's origins can be found here.