Connecting to a remote database from a database administration tool
Nearly every business uses relational databases to store information, and eventually, we’ve all needed to access the database on our server to read the data or manually add new data. This article will be useful for anyone wanting to access their databases on a cloud platform such as Google Cloud or AWS using a straightforward database tool of their choice, which will be DBeaver
for this article.
DBeaver
DBeaver is a free SQL client that is used to connect to databases such as MySQL. DBeaver is available in Windows, Linux, and macOS. We will be installing the tool in Windows using this link.
G-Cloud
G-Cloud or Google cloud platform is a set of cloud computing services provided by Google. One of those services that offers fully managed relational database service is Google Cloud SQL.
For the sake of this article, we have already created a G-Cloud project having an instance of MySQL database.
Finding the Instance IP Address in G-Cloud
First, we will need to find the IP address of the database instance which will be required in order to connect to the remote database from our local database tool. To find the IP address, select the SQL
option from the left menu bar and select the database instance you want to connect to.
After selecting the database instance, you will be directed to an instance overview page where you will find the IP address of your instance which will be used for connecting to it.
But before you switch over to DBeaver,
there is one more step that needs to be done. From the left menu bar on the same page, select Connections
, and under the Authorized networks
section, enter your personal IP address which you can get by typing My IP
on google.
Note: Be sure to update your IP address in the
Connections
page before connecting to the instance, since your IP may change over time, sometimes even daily.
AWS
AWS (Amazon Web Services) is a similar cloud platform that provides on-demand cloud services. AWS also has a Relation Database Service (RDS) which is used to create a database instance with a public IP.
Finding the Instance IP Address in AWS
Similar to the G-Cloud, we will find the IP address of the RDS instance in AWS under the Instances
tab.
Similarly, we will need to authorize our IP address which can be done under the security-group
tab by clicking on the Edit inbound rules
button.
Note: You can also give read/write permissions to Authorized Users on both G-Cloud and AWS by using Cloud SQL Roles and AWS IAM Console.
Connecting to the instance using DBeaver
Now we are ready to head over to the SQL tool DBeaver.
Open DBeaver
and from the top menu bar, select New Database Connection
found under Database.
A new popup will open with a variety of Relational Database Management Systems (RDBMS)
options. We will select MySQL
which is the chosen system for this article.
After clicking the next button, you will be directed to a connection settings window where you will be required to enter the necessary information. In theServer host
and Database
field under the main
tab, enter the database IP address and the name of your database. You will also be required to enter the username
and password
which is root
with no password in default.
You can test your connection by using the Test Connection
button and if everything goes right, you will be able to see a success message. Finally, you can click on Finish
the button and use your database from your local database tool.
And that completes the process of connecting DBeaver
to a distant MySQL
database. Happy Coding!