Posts Tagged ‘powershell’

Connect PowerShell to MySQL

Using the MySQL.NET connector, it’s possible to connect to a MySQL database using PowerShell. /* replace path with your local /path/to/mysql/connector/MySQL.Data.dll */ [void][system.reflection.Assembly]::LoadFrom(\"d:\\tools\\mysql-connector\\bin\\MySQL.Data.dll\") $myconnection = New-Object MySql.Data.MySqlClient.MySqlConnection $myconnection.ConnectionString = \"server=localhost;user id=test;password=test;database=test;pooling=false\" $myconnection.Open() $mycommand = New-Object MySql.Data.MySqlClient.MySqlCommand $mycommand.Connection = $myconnection $mycommand.CommandText = "SHOW TABLES" $myreader = $mycommand.ExecuteReader() while($myreader.Read()){ $myreader.GetString(0) } This example will display all tables [...]

More »