Windows Powershell provides you with a command line utility to automate some features in Windows, including a connection to a MySQL server. Powershell lets you run queries from a command line without the need for third party software. You use the MySQL DLL file on the server to connect to the database. After you connect to MySQL you can manipulate the data and tables from the command line.
- Skill level:
Other People Are Reading
Things you need
- MySQL connector installed
Click the Windows "Start" button and type "MySQL.Data.dll" in the search text box. Press "Enter" to do a search for the file. You need the location of the file to connect from Powershell. In the results window take note of the directory where the DLL file is located.
Click the Windows "Start" button and select "All Programs. Click "Accessories" then click "Windows PowerShell." Click the "Windows PowerShell" icon to open the command line tool.
Type or copy the following text into the Powershell window and press "Enter":
Replace "C:\location" with the location of the DLL file.
Type the following code to create the connection to the server so you can query the database tables:
run-MySQLQuery -ConnectionString "Server=localhost;Uid=user;Pwd=pw;database=mydb;"
Replace "user" and "pw" with the user name and password needed to connect to the database server. Replace "mydb" with the name of the database. This code connects to the database so you can now run queries or view security information for the MySQL server.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for