Thursday 5 February 2015

Migrate MS SQL Apelon content to MySQL

Download Microsoft® SQL Server® 2008 R2 Service Pack 1
http://www.microsoft.com/en-gb/download 

Run installer
open terminal

sqlcmd -S \SQLExpress

restore filelistonly from disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak';
GO

- Note: In order to avoid the following error:
Msg 3201, Level 16, State 2, Server WIN-1VMUV8AJRHG\SQLEXPRESS, Line 1
Cannot open backup device 'C:\Users\Administrator\Downloads\dts_20150112_ 20000.
bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Server WIN-1VMUV8AJRHG\SQLEXPRESS, Line 1
RESTORE FILELIST is terminating abnormally.

- you must allow read/write permissions to SQL Server on the folder where you have placed the .bak file or you can use the Backup folder of the sql server (e.g., C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\) 

- the terminal will show the content of the backup.  Yow need the first fields that tell you the logical names :


Teminal:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>sqlcmd -S \SQLExpress
1> restore filelistonly from disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak';
2> GO
LogicalName
                                                 PhysicalName


                                                                      Type FileG
roupName
                                            Size                 MaxSize
      FileId               CreateLSN                   DropLSN
   UniqueId                             ReadOnlyLSN                 ReadWriteLSN
                BackupSizeInBytes    SourceBlockSize FileGroupId LogGroupGUID
                      DifferentialBaseLSN         DifferentialBaseGUID
       IsReadOnly IsPresent TDEThumbprint
--------------------------------------------------------------------------------
------------------------------------------------ -------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------- ---- -----
--------------------------------------------------------------------------------
------------------------------------------- -------------------- ---------------
----- -------------------- --------------------------- -------------------------
-- ------------------------------------ --------------------------- ------------
--------------- -------------------- --------------- ----------- ---------------
--------------------- --------------------------- ------------------------------
------ ---------- --------- ------------------------------------------
dts
                                                 c:\Program Files\Microsoft SQL
Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts.mdf


                                                                      D    PRIMA
RY
                                                         9437184       351843720
80640                    1                           0
0 0F1FD1EB-8A12-4679-A531-F8FB9D3DBB66                           0
              0              9437184             512           1 NULL
                               217000000005800037 EA55F188-39C9-46F4-889B-AC8AD2
763D23          0         1 NULL
dts_log
                                                 c:\Program Files\Microsoft SQL
Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts_1.ldf


                                                                      L    NULL

                                                         1048576        21990232
55552                    2                           0
0 61A7EBA2-5D83-41DC-9A0E-5C8BDBFBA107                           0
              0                    0             512           0 NULL
                                                0 00000000-0000-0000-0000-000000
000000          0         1 NULL

(2 rows affected)
1>



Restore database

RESTORE DATABASE dts FROM disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak'
WITH 
   MOVE 'dts' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts.mdf', 
   MOVE 'dts_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts_1.ldf';
GO



Teminal:

1> RESTORE DATABASE dts FROM disk='C:\Program Files\Microsoft SQL Server\MSSQL10
_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak'
2> WITH
3>    MOVE 'dts' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS
\MSSQL\DATA\dts.mdf',
4>    MOVE 'dts_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXP
RESS\MSSQL\DATA\dts_1.ldf';
5> GO
Processed 1152 pages for database 'dst', file 'dts' on file 1.
Processed 1 pages for database 'dst', file 'dts_log' on file 1.
RESTORE DATABASE successfully processed 1153 pages in 0.372 seconds (24.214 MB/s
ec).
1>



MySQL Workbench migration

- Check if you have an OBDC driver for SQL server


Open the migration wizard on MySQL Workbench and select on Stored Connection (Local Instance M


- leave the use and password empty
- test connection

define the connection details of your local mysql server


- Click on Store in ... and set the password of your mysql database
- Test connection 


- Select schematas to migrate




- Click next
- Select all objects
- Modify the following sql script

- and set COLLATE utf8_bin :


- Click apply








References

Evernote helps you remember everything and get organized effortlessly. Download Evernote.

No comments:

Post a Comment