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.
Things You'll 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.
How to Connect to the MySQL Server
When you need to add or modify information to a database located on the server, you'll need to connect to the MySQL...