2011-03-16 69 views

回答

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。 :) – 2011-03-20 14:52:30

相關問題