Powershell: Run MySQL Querys with Powershell

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestShare on TumblrShare on RedditEmail this to someone

Powershell Header
In our Hosting enviroment we are now using MS SQL Servers for our back-end. But there are still some MySQL Server left which store some data. Now since we do a lot of automation with Windows Powersehll I wrote a function to run MySQL querys with Powershell.

First you have to install the MySQL .NET Connector or just copy the MySql.Data.dll from the MySQL.

You can now load this:

With DLL File:

or if you have installed the MySQL .NET Connector:

Now basiclly this function does everything for you:

You can use this Powershell function like this:

If you wanna run more than one command you could do something like this:

If you need more information about Powershell and MySQL Mark Alexander Bain wrote a blog post about this.

And if you need a local MySQL Server on your machine to test this, you could use Microsoft Platform Installer to install MySQL and other cool Webtools.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestShare on TumblrShare on RedditEmail this to someone