2011-03-16 1 views
1

제목 아래에 Windows에서 일부 데이터베이스를 제외하고 mysqldump를 사용할 수 있는지 알고 싶습니다. 이미 봤했는데 내가 이걸 발견했습니다외부 도구가없는 창에서 mysqldump의 데이터베이스를 제외합니다.

http://datacharmer.blogspot.com/2010/12/excluding-databases-from-mysqldump.html

하지만 난 그래서 PowerShell을, gnuwin32와 같은 외부 도구를 필요로하지 않는 창에서 해결책을 찾고 있어요. 감사.

답변

3

이것은 내 마지막 스크립트입니다. 그것은 분명히 ODBC 드라이버가 필요합니다.

set cn = CreateObject("ADODB.Connection") 
set rs = CreateObject("ADODB.Recordset") 
Set oShell = WScript.CreateObject("WScript.Shell") 
user = "my_user" 
password = "my_password" 
mysqlPath = "C:\mysql_path\bin\mysqldump.exe" 
bkDate = DatePart("yyyy",Date) _ 
     & Right("0" & DatePart("m",Date), 2) _ 
     & Right("0" & DatePart("d",Date), 2) 
dumpPath = "c:\my_path\dump_" & bkDate & ".txt" 
strDbList = "" 
cn.connectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;User="&user&";Password="&password&";" 
cn.open 
rs.open "select schema_name from information_schema.schemata where schema_name not in('db1','db2','.....') order by schema_name", cn, 3 
rs.MoveFirst 
while not rs.eof 
    strDbList = strDbList & rs(0) & " " 
    rs.movenext 
wend 
oshell.run "cmd /k " & mysqlPath & " -u" & user & " -p" & password & " --database " & strDbList & "> " & chr(34) & dumpPath & chr(34),0  
cn.close 
set oShell = nothing               
set rs = nothing 

다른 사람에게 도움이되기를 바랍니다.

1

원하는 언어로 올바른 출력 선택을하기 위해 짧은 코드를 쉽게 작성할 수 있습니다.

+0

+1. 나는 vbscript에서 생각하지 않았다. :) –

관련 문제