MySQL for Visual Studio  /  Making a Connection

Chapter 4 Making a Connection

MySQL for Visual Studio leverages and extends the connection capabilities of Visual Studio to create and store MySQL connections. To ensure access to the full set of connection options, install the most recent version of MySQL Connector/NET on the client computer (see Minimum Requirements).

MySQL for Visual Studio provides the following two distinct release series:

  • MySQL for Visual Studio 1.2 release series.  Provides General Availability (GA) releases for use with MySQL 5.6, 5.7, and 8.0 servers. Connections can be made using the classic MySQL protocol only. Both PEM and PFX certificates are permitted with Connector/NET 8.0.16 or higher when the server supports SSL connections. Unencrypted connections are supported by the latest versions of MySQL Connector/NET. To add or modify MySQL data connections, use the Server Explorer management console in Visual Studio (see Section 4.1, “Connect Using Server Explorer”).

  • MySQL for Visual Studio 2.0 release series.  Provides a development release series for use with MySQL 5.6 and 5.7 servers (version 2.0.5 is the current milestone). Basic connections are supported for both the classic MySQL protocol and X Protocol (33060 default port number). When the server supports SSL connections, PEM and PFX certificates are permitted with X Protocol; PFX certificates are permitted with the classic MySQL protocol. Use either MySQL Connections Manager or Server Explorer in Visual Studio to add or modify classic MySQL protocol connections. To add or modify X Protocol connections, use MySQL Connections Manager only (see Section 4.2, “Connect Using MySQL Connections Manager”).

    MySQL Connections Manager was introduced in the MySQL for Visual Studio 2.0 release series to simplify the creation and management of MySQL server connections within Visual Studio. From MySQL Connections Manager, you have the option to migrate all stored connections to MySQL Workbench (if it is installed), making MySQL Workbench a central repository for MySQL connections.

Basic Connections in Visual Studio

A basic connection is either unencrypted or encrypted (in MySQL 8.0, SSL is enabled by default) and the connection is made using standard TPC/IP, which is the default connection method in MySQL for Visual Studio to connect to the MySQL RDBMS. Basic connections are easy to configure, particularly if the client application and MySQL server are on the same host computer or operate within the same local area network. For instructions on how to create a basic connection to MySQL from within Visual Studio, see Basic Connections with Server Explorer or Basic Connections with MySQL Connections Manager.

SSL Connections in Visual Studio

MySQL Server uses the PEM format for certificates and private keys. Connector/NET 8.0.17 enables the use of either PEM or PFX certificates with the classic MySQL protocol when Server Explorer in Visual Studio (with MySQL for Visual Studio 1.2.9 or higher) is used to add or modify the data connection.

Both the MySQL server and the client must be configured to enable SSL encryption (see Using Encrypted Connections). In addition to providing the paths to certificate files, the client can specify the SSL mode to use for connections. When using Server Explorer, the SSL mode value is set with an advanced property. MySQL Connections Manager provides the Use SSL Encryption drop-down list with similar values. The following table describes the optional SSL values to select (and the files to specify) with each tool.

Table 4.1 SSL Mode Values

Server Explorer Connections Manager Description
None No Do not use SSL. No SSL files are required.
Preferred If Available Use SSL if the server supports it, but allow connection in all cases. Preferred is the default value with Connector/NET 8.0.11 or higher. No SSL files are required; however, providing the SSL CA file (with either a .pem or .pfx file extension) is the best practice for connections made to MySQL 8.0 servers.
Required Require Always use SSL and deny a connection if the server does not support SSL. Do not perform server certificate validation. No SSL files are required.
VerifyCA Require and Verify CA Always use SSL. Validate the certificate authorities (CA), but tolerate a name mismatch. Requires the SSL CA file. Use either a .pem or .pfx file extension.
VerifyFull Require and Verify Identity Always use SSL and fail if the host name is not correct. Requires valid SSL CA, SSL Cert, and SSL Key files for PEM (.pem file extension). Requires the SSL CA file for PFX certificates (.pfx file extension).