IT TIP

SQL Server .bak 파일을 MySQL로 가져 오는 방법은 무엇입니까?

itqueen 2020. 12. 8. 20:33
반응형

SQL Server .bak 파일을 MySQL로 가져 오는 방법은 무엇입니까?


제목은 자명합니다. 이런 종류의 수입을 직접하는 방법이 있습니까?


SQL 서버의 .BAK 파일은 MTF (Microsoft Tape Format) 참조 : http://www.fpns.net/willy/msbackup.htm

bak 파일에는 SQL 서버가 데이터베이스를 저장하는 데 사용하는 LDF 및 MDF 파일이 포함될 수 있습니다.

이를 추출하려면 SQL 서버를 사용해야합니다. SQL Server Express는 무료이며 작업을 수행합니다.

따라서 SQL Server Express 에디션을 설치하고 SQL Server Powershell을 엽니 다. 실행 sqlcmd -S <COMPUTERNAME>\SQLExpress(관리자로 로그인 한 동안)

그런 다음 다음 명령을 실행하십시오.

restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO

그러면 백업 내용이 나열됩니다. 필요한 것은 논리적 이름을 알려주는 첫 번째 필드입니다. 하나는 실제 데이터베이스이고 다른 하나는 로그 파일입니다.

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

이 시점에서 데이터베이스의 압축을 푼 다음 Microsoft의 "Sql Web Data Administrator"를 설치합니다. 이 내보내기 도구함께 사용 하면 데이터베이스가 포함 된 SQL 스크립트를 갖게됩니다.


나는 그것을 직접하는 방법을 찾지 못했습니다.

대신 bak 파일을 SQL Server 2008 Express로 가져온 다음 MySQL Migration Toolkit 을 사용했습니다 .

매력처럼 일했다!


MySql에는 Microsoft SQL에서 db를 가져 오는 응용 프로그램이 있습니다. 단계 :

  1. MySql Workbench 열기
  2. "데이터베이스 마이그레이션"을 클릭합니다 (표시되지 않는 경우 MySql 업데이트에서 설치해야합니다).
  3. 간단한 마법사를 사용하여 마이그레이션 작업 목록을 따르십시오.

내 MySQL 배경은 제한적이지만 그렇게 할 운이별로 없다고 생각합니다. 그러나 db를 MSSQL 서버로 복원 한 다음 SSIS 또는 DTS 패키지를 만들어 테이블과 데이터를 MySQL 서버로 전송하여 모든 데이터를 마이그레이션 할 수 있어야합니다.

도움이 되었기를 바랍니다


SQL Server의 .bak 파일은 해당 데이터베이스 언어에 고유하며 MySQL과 호환되지 않습니다.

etlalchemy사용 하여 SQL Server 데이터베이스를 MySQL로 마이그레이션하십시오. 다른 RDBMS 간의 쉬운 마이그레이션을 용이하게하기 위해 만든 오픈 소스 도구입니다.

빠른 설치 및 예제는 여기 github 페이지 에서 제공되며 프로젝트의 기원에 대한 자세한 설명은 여기 에서 찾을 수 있습니다 .


나는 그것을 매우 의심한다. Levi가 말한 것처럼 DTS / SSIS를 사용하여이를 수행 할 수 있습니다. 실제로 데이터를 가져 오지 않고 프로세스를 시작하는 것이 좋습니다. 기본 테이블 구조를 모으기 위해 충분합니다. 그런 다음 생성 될 수있는 구조가 기껏해야 흔들 리기 때문에 결과 테이블 구조를 변경하고 싶을 것입니다.

또한이 작업을 한 단계 더 진행하고 모든 데이터 첫 번째 na 문자열 (varchar) 형식을 사용하는 준비 영역을 만들어야 할 수도 있습니다. 그런 다음 유효성 검사 및 변환을 수행하여 "실제"데이터베이스로 가져 오는 스크립트를 만들 수 있습니다. 특히 날짜를 처리 할 때 두 데이터베이스가 항상 잘 작동하는 것은 아니기 때문입니다.


내가 사용한 방법에는 Richard Harrison의 방법의 일부가 포함되었습니다.

따라서 SQL Server 2008 Express 에디션을 설치하고

웹 플랫폼 설치 프로그램 "wpilauncher_n.exe"를 다운로드해야합니다.이 설치가 완료되면 데이터베이스 선택을 클릭하십시오 (프레임 워크 및 런타임도 다운로드해야 함).

설치 후 Windows 명령 프롬프트로 이동하여 다음을 수행하십시오.

sqlcmd -S \ SQLExpress 사용 (관리자로 로그인 한 상태에서)

그런 다음 다음 명령을 실행하십시오.

disk = 'c : \ temp \ mydbName-2009-09-29-v10.bak'에서만 파일 목록 복원; GO 이것은 백업 내용을 나열합니다. 필요한 것은 논리적 이름을 알려주는 첫 번째 필드입니다. 하나는 실제 데이터베이스이고 다른 하나는 로그 파일입니다.

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 '; 가다

웹 플랫폼 설치 프로그램을 시작하고 새로운 기능 탭에서 SQL Server Management Studio를 설치하고 db를 탐색하여 데이터가 있는지 확인했습니다.

그 시점에서 MSSQL "SQL 가져 오기 및 내보내기 마법사"에 포함 된 도구를 사용해 보았지만 csv 덤프의 결과에는 열 이름 만 포함되었습니다.

대신 SQL Server Management Studio에서 "select * from users"와 같은 쿼리 결과를 내보냈습니다.


SQL Server 데이터베이스는 매우 Microsoft 소유입니다. 내가 생각할 수있는 두 가지 옵션은 다음과 같습니다.

  1. CSV, XML 또는 유사한 형식으로 데이터베이스를 덤프 한 다음 MySQL에로드합니다.

  2. 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.

참고URL : https://stackoverflow.com/questions/156279/how-to-import-a-sql-server-bak-file-into-mysql

반응형