dbdump.ps1


$MySQLPath = "c:\xampp\mysql\bin"
$Hostname = "localhost"
$Username = "root"
$Password = ""

# Get list of Databases
$Databases = [System.Collections.Generic.List[String]](& $MySQLPath\mysql.exe -h"$Hostname" -u"$Username" -p"$Password" -B -N -e"show databases;")

# Remove databases from list we don't want
[void]$Databases.Remove("information_schema")
[void]$Databases.Remove("mysql")
[void]$Databases.Remove("performance_schema")
# Remove databases from list we don't want
[void]$Databases.Remove("dol31")
[void]$Databases.Remove("gb4")

# Dump database to .SQL file
& $MySQLPath\mysqldump.exe -h"$HostName" -u"$Username" -p"$Password" -B $($Databases) | Out-File "e:\local\mysql.sql"


.bat 에서 실행방법

Powershell.exe -executionpolicy remotesigned -File e:\local\dbdump.ps1

,