How to Connect a Database via a VPN

How to Connect a Database via a VPN?

Data storage and management systems continue to advance, which inevitably brings a need for more secure and efficient data exchange. It is considered a top priority for companies and individual users worldwide, contributing to a growing adoption of VPN services. In fact, even industry leaders are implementing their own strategies. Google, for instance, recently announced that Google One subscribers will have VPN access included in their plan. Initiatives like this underline the importance of staying secure online.

A reliable way to access data safely is by using a VPN to connect to your database. That’s because VPNs can encrypt your transmission online by creating a secure tunnel between your device and the VPN server.

This article will walk through the steps of connecting to a database via a VPN. Before you proceed, however, be sure to select the VPN service that will suit your intended purposes. There are a plethora of free and paid options, with each having its own signature features. Once you’ve chosen and installed your VPN, follow the guide below on how to use it for setting up a connection to your database.

Build a database user profile

The first step is to create a database user. Note that the process may vary depending on the database provider you are using. Some of the most popular are MicrosoftSQL, MySQL, and MongoDB.

For more seamless integration, work on a data platform environment to establish the connection setup. A data platform is a set of software and hardware with features that work well together to meet the specific needs of a user or business. The advantages of a data platform include interoperability, compatibility, and scalability. This can give you better chances of running configurations smoothly, including a connection set up between a VPN and a database. Check your database provider’s website to know what other tools work best for their platform. This is also where you can find the exact information on how to create a user profile.

Create a dedicated VPN user account

Once you have a database user account, you may proceed to create a VPN user. It’s advisable to have a dedicated profile for each of your VPN to database connections. This will make it easier to track users on your account and ensure that your system remains secure.

Add your new credentials to the system

Next is to enter your user and connection information on the data platform you are using. This can be done by adding a new data source – typically via its dashboard or GUI. Doing so will allow the system to recognize and authorize the connection you are setting up. In some cases, there are icons for the databases that are part of the platform. Simply select the correct option and enter the required information.

Configure TCP/IP access

You also need to enable TCP/IP access. This involves setting up protocols and ports, as well as configuring your firewall to allow access from your IP addresses. It’s an important step so the connection between your VPN and the database will not be blocked by your computer. Database ports differ depending on your provider. Here are the default ports for the ones mentioned earlier:

MicrosoftSQL: 1433

MySQL: 3306

MongoDB: 27017

As for IP addresses, the default is 127.0.0.1 which is the localhost. You can change this to the public IP address of your server or a local area network (LAN) address.

Next is to place exceptions on your firewall. If you are using Windows Firewall, it’s required to set up Inbound and Outbound rules, and the necessary details should match your database type. For example, using a SQL database will need the following configuration:

  • Open Windows Firewall, then navigate to Advanced Security.
  • On the lefthand-side menu, click Inbound Rules.
  • A menu will open on the right side labeled Actions. Click ‘New Rule’. Alternatively, you may right-click on the Inbound Rules option and select ‘New Rule…’ from the dialog box.
  • The ‘New Inbound Rule Wizard’ window will open. Select ‘Port’ and click Next.
  • In the ‘Protocols and Ports’ section, select ‘UDP’ in the first part and ‘Specific local ports’ in the second part. Use MySQL port number. Click Next.
  • In the Action window, choose ‘Allow the connection’.
  • For Profile, enable the options that you use for connecting to the internet: corporate domain, private, or public.
  • Input your preferred name for the Rule and click Finish.
  • Open another New Rule instance and on the Rule Type window, select Custom then click Next.
  • In the next section, select Customize. This will open the list of database instances you have. Select the one you will connect to via a VPN.
  • Give the Rule a name and click Finish.

Note that if you’re connecting to the database remotely, you need to enable this option. For a SQL database, go to its Properties section and select Connections. Select “Allow remote connections to this server” in the Remote Server Connections settings and set query timeout. 600 is the default value. Click OK to finish.

Set encryption for the connection

Open the encryption section of your data platform. For encryption type, select your VPN. You also need to enter the gateway address, which is the IP address of your VPN server. Check with your provider for the exact details.

It will also ask for your username and password. Input the details of the dedicated VPN account you created. When you have entered all the required information, save and test your setup.

Turn your VPN on and use a program that needs to access the database you set for the connection. If the operations you input are executed without a hitch, this means the connection is running properly. You are now connected to your database via a VPN, ensuring that your data remains safe and secure. Remember to combine the security provided by your VPN with other protective measures to maximize the safety of your data.