MySQL and Windows  /  ...  /  Connect Using Server Explorer

6.4.1 Connect Using Server Explorer

This section describes how to create a new connection with or without encryption. After a 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. The instructions for setting up connections are provided in these sections.

To modify or 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.

Basic Connections with Server Explorer

To create a connection to an existing MySQL database:

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

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

  3. From the Add Connection window, click Change to open the Change Data Source dialog box, then do the following:

    1. Select MySQL Database from the list of data sources. Alternatively, you can select <other>, if MySQL Database is absent.

    2. Select .NET Framework Data Provider for MySQL as the data provider.

    3. Click OK to return to the Add Connections window.

  4. Type a value for each of the following connection settings:

    • Server name:

      The name or IP address of the computer hosting the MySQL server. For example, localhost if the MySQL server is installed on the local computer.

    • User name:

      The name of a valid MySQL database user account.

    • Password:

      The password of the user account specified previously. Optionally, click Save my password to avoid having to enter the password in the Modify Connections window for each connection session.

    • Database name:

      The database to use as the default schema. You can leave the name blank and select a default schema later from the list of schema on the target server.

    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 box opens.

  5. Click OK to create and store the new connection. The new connection with its tables, views, stored procedures, stored functions, and UDFs now appears within the Data Connections node of Server Explorer.

SSL Connections with Server Explorer

You can enable SSL encryption for a classic MySQL protocol connection from Server Explorer. Both SSL PEM and PFX certificate formats are permitted. In addition, MySQL Connector/NET version 8.0.17 must be installed on the client host.

To create a connection with SSL encryption enabled:

  1. Add and test a new basic connection (see Basic Connections with Server Explorer.

    To modify an existing connection, right-click the connection node within Data Connections and select Modify Connection.

  2. In the Add (or Modify) Connection window, click Advanced to open the Advanced Properties dialog box. Advanced properties are categorized and presented in a two-column list, showing the property name and value field (or value list). Default values are not shown.

  3. In the Connection property category, do the following:

    1. Select Connection Protocol and then select Socket from the value list (use the arrow in the value field to open the list). This property sets the connection protocol to use standard TCP/IP.

    2. Select Port and type 3306 in the value field.

  4. In the Authentication property category, select Ssl Mode and choose the type of mode that best represents your connection. For a description of each mode and the required files, see Table 6.2, “SSL Mode Values”.

    • For SSL PEM, use the Ssl CA, Ssl Cert, and Ssl Key properties to add the required files (must have a .pem file extension).

    • For SSL PFX (PKCS#12 format), use the Certificate File, Certificate Password, Certificate Store Location, and Certificate Thumbprint properties to add the required information or files (must have a .pfx file extension).

    Click OK to close the Advanced Properties dialog box.

  5. Click Test Connection and adjust the property values if needed.

  6. Click OK to create and store the new or modified connection.

SSH Connections with Server Explorer

Standard TCP/IP over SSH is supported for classic MySQL protocol connections only. In addition, MySQL Connector/NET version 8.0.17 must be installed on the client host and the SSH server must be configured in advance.

To create a connection for standard TCP/IP over SSH:

  1. Add and test a new basic connection (see Basic Connections with Server Explorer.

    To modify an existing connection, right-click the connection node within Data Connections and select Modify Connection.

  2. In the Add (or Modify) Connection window, click Advanced to open the Advanced Properties dialog box. Advanced properties are categorized and presented in a two-column list, showing the property name and value field (or value list). Default values are not shown.

  3. In the Connection property category, do the following:

    1. Select Connection Protocol and then select Socket from the value list (use the arrow in the value field to open the list). This property sets the connection protocol to use standard TCP/IP.

    2. Select Port and type 3306 in the value field.

  4. In the Authentication property category, select Ssl Mode and then choose the type of mode that best represents your connection. For a description of each mode and the required files, see Table 6.2, “SSL Mode Values”.

  5. In the SSH property category, add values to the properties that apply to your connection (see SSH Connections in Visual Studio). Click OK to close the Advanced Properties dialog box.

  6. Click Test Connection and adjust the property values if needed.

  7. Click OK to create and store the new or modified connection.