Digital Efforts

Internet Consulting and Development

Discussions

Here's a simple script that demonstrates Powershell access to MySQL.

[void][system.reflection.Assembly]::LoadFrom("C:\Program Files\MySQL\MySQL Connector Net 5.2.3\Binaries\.NET 2.0\MySQL.Data.dll"
 
$myconnection = New-Object MySql.Data.MySqlClient.MySqlConnection 
$myconnection.ConnectionString = "server=localhost;user id=root;password=password;database=mysql;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) } 
 
$myreader.Close() 
 
$myconnection.Close() 

0 Comments Share Print
Gravatar
digitalefforts Sunday, March 01, 2009 @ 9:16 pm
Site © Copyright 2007-2010, BubbleLife Media LLC Privacy Policy Terms of Use
Wednesday, March 10, 2010 11:49 PM
Powered by BubbleCommunities 0.9.0.2882
BUBBLECOMMUNITIES, BUBBLELIFE MEDIA, BUBBLECOMMUNITIES and NEIGHBORHOOD BRANDS are trademarks of BubbleLife Media LLC. Unauthorized use is prohibited.