This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Enable Remote MySQL Connection

Updated on  8th June

4 Min Read
remote mysql connection
Reading Time: 4 minutes

Imagine you are part of a big team of developers with multiple roles, working on large software products, complex database schema and connection. You need to work with SQL queries and create a connection remotely from different locations. To enable remote MySQL connection, you need to grant remote MySQL access on your hosting server and whitelist the IPs of your developers.

Although this is a simple process, it is not very secure.  A better approach comprises of adding developers as team members in your hosting solution, and then allowing them to connect to MySQL database remotely? This will allow you to create a secure environment, and let your remote developers work with the centralized database.

Enable Remote MySQL Connection
1. Add a Developer as a Team Member?
2. Whitelist IP of the developer
3. Apply Remote Access Configs
4. MYSQL Client Connection
5. Final Words

On Cloudways PHP hosting platform, you can easily do this by following the few steps outlined in this article. By default, Cloudways does not allow MySQL access from remote hosts because of the inherent security risks to the servers and applications.

In this article I’ll show you how to access MySQL database remotely in your projects. I will cover the following topics:

  • Add a developer as a team member
  • Whitelist IPs
  • Apply remote access configs
  • MySQL Client Connection

Add a Developer as a Team Member

At Cloudways there are two ways you can give access to developers. The first is to give them SFTP access. The second is to add them as a team member so they are comfortable and can be more independent with their servers and applications. For using remote MySQL connection, the best option is to add your developer as a team member first, before granting the permissions and whitelisting his public IP.

Note: Only account owners can create Team Members. If an email address is already associated with a Cloudways account (Trial or Full), it cannot be used as a team member account.

Simply log into the Cloudways Platform with your credentials, and then click on the ‘team’ subtitle in the top menu.

Now, click on the Add icon on the top menu bar and choose Add Member.

 

Provide the name and email address of your team member and select the Job Title from the drop-down menu. Once that is done, set his/her status to Active.

 

Whitelist IP of the developer

The next step is to find your public IP and add it to the targeted server. Then, move to the server access detail page and click on security tab. Add the IP address to the “Add IP to Whitelist” text area and click the “Add” button. You can use this method to add multiple IP addresses if you need to. After this, simply click the save button.  

You can also use sites like whatismyip to find your public IP.

whitelist ip

 

Apply Remote Access Configs

As you whitelist your IP, you can copy your database credentials from application access details page and add to your php connection code like this:

As you can see above, I’ve added the Cloudways server IP address in host connection. That’s all you need to do to create remote connection. You are then good to go for creating queries and manipulating the database.

MYSQL Client Connection

In the explanation above, I explained how to set up a remote MySQL connection at Cloudways and then use it in your code. Sometimes, however, you need to use MySQL clients to work with databases. You can also connect clients like SQLYOG and Mysql workbench. In sqlyog you just need to pass on the Cloudways server IP and database credentials to create db connection.

connect to mysql host

You will now see your database is connected to sqlyog.

mysql database connected

Final Words

Cloudways provides an easy way for developers and software business owners to work with peace of mind and focus on the project in front of them. Just like enabling remote MySQL connection, you’re also able to complete many other actions in just a few clicks, like installing SSL certificates, CDN, DNS management, and so on. All you need to do to access all we have to offer is sign-up, where you will then be able to launch your servers and applications with little hassle, thanks to this straightforward guide!

Share your opinion in the comment section. COMMENT NOW

Shahroze Nawaz

Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at shahroze.nawaz@cloudways.com

Create PHP websites without the worry of server management.

Deploy your PHP app on optimized PHP hosting servers.

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.