MySQL for Visual Studio  /  Making a Connection

Chapter 4 Making a Connection

MySQL for Visual Studio enables you to create, modify, and delete connections to MySQL databases.

Connect with Server Explorer

To create a connection with a MySQL database, perform the following steps:

  1. Start Visual Studio and open the Server Explorer window by clicking View and then Server Explorer from the main menu.

  2. Right-click the Data Connections node and click Add Connection.

  3. From the Add Connection dialog, click Change and select the MySQL Database as a data source.

    Figure 4.1 Add Connection Context Menu

    Add Connection Context Menu

  4. From the Change Data Source dialog, select MySQL Database from the list of data sources (or the <other> option, if MySQL Database is absent), and leave .NET Framework Data Provider for MySQL as the data provider.

    Figure 4.2 Choose Data Source

    Choose Data Source

  5. Input the connection settings: the server host name (for example, localhost if the MySQL server is installed on the local machine), the user name, the password, and the default schema name. Note that you must specify the default schema name to open the connection.

    Figure 4.3 Add Connection Dialog

    Add Connection Dialog

  6. You can also set the port to connect with the MySQL server by clicking Advanced. To test connection with the MySQL server, set the server host name, the user name and the password, and then click Test Connection. If the test succeeds, the success confirmation dialog opens.

  7. After you set all settings and test the connection, click OK. The newly created connection is displayed in Server Explorer. Now you can work with the MySQL server through standard Server Explorer GUI.

    Figure 4.4 New Data Connection

    New Data Connection

After the connection is successfully established, all settings are saved for future use. When you start Visual Studio for the next time, open the connection node in Server Explorer to establish a connection to the MySQL server again.

To modify and delete a connection, use the Server Explorer context menu for the corresponding node. You can modify any of the settings by overwriting the existing values with new ones. Note that the connection may be modified or deleted only if no active editor for its objects is opened: otherwise, you may lose your data.

Connect with SSL and the X Protocol

Connections that use the X Protocol can be configured to use SSL with PEM files. To use SSL encryption, connections must be created using the MySQL Connections Manager included with MySQL for Visual Studio 2.0.3 (or later) or with MySQL Workbench.

Note

SSL must be enabled in the target MySQL server instance and the X Plugin must be installed to support connections using SSL encryption and the X Protocol.

To create a connection to a MySQL database using SSL encryption and the X Protocol, perform the following steps:

  1. Click the MySQL icon ( ) in Visual Studio Server Explorer to open the MySQL Connections Manager window.

  2. Click Add New Connection to create a new connection.

  3. In the Parameters tab, add the host name, port, user name and password, and a default schema. Click Test Connection to verify the connection information.

    Figure 4.5 MySQL Server Connection Parameter Tab

    MySQL Server Connection: Parameter tab.

  4. In the SSL tab, add a path to the SSL CA, SSL CERT, and SSL Key files within the SSL PEM area. Click Test Connection to verify the connection information.

    Figure 4.6 MySQL Server Connection SSL Tab

    MySQL Server Connection: SSL tab.

  5. Click OK to save the connection and return to the MySQL Connections Manager window.

    Note

    You must close and then reopen MySQL Connections Manager to apply the default schema.

  6. Double-click the new SSL connection to add it to Server Explorer (or select the connection and click OK). To open the JavaScript or Python code editor, right-click the connection in Server Explorer and then select an editor.


User Comments
Sign Up Login You must be logged in to post a comment.