Digital Efforts

Internet Consulting and Development

Already a member?  Login
Find by Topic
Blog

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() 

Share Print
Gravatar
digitalefforts Sunday, March 01, 2009 @ 10:16 pm
Site © Copyright 2007-2010, BubbleLife Media LLC Privacy Policy Terms of Use
Friday, September 03, 2010 12:46 AM
Powered by BubbleCommunities 0.9.0.3550.64
BUBBLELIFE, BUBBLELIFE MEDIA, BUBBLECOMMUNITIES and NEIGHBORHOOD BRANDS are trademarks of BubbleLife Media LLC. Unauthorized use is prohibited.