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 Using Server Explorer

To create a connection to an existing MySQL database, perform the following steps:

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

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

  3. From the Add Connection window, click Change to open the Change Data Source dialog, 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 dialog.

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

    • Server name:

      For example, localhost if the MySQL server is installed on the local computer.

    • User name:

      The name of a valid MySQL database user account, such as root.

    • Password:

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

    • Database name:

      A default schema name is required to open the connection. Select a name from the list.

    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.

  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 list of Server Explorer.

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