Introduction
If you’re a web developer working with MySQL databases hosted on a shared webhost (e.g. MochaHost), you might need to connect to them remotely for various reasons. In this guide, we’ll walk you through the process of connecting to a remote MySQL database using HeidiSQL, a user-friendly and powerful database management tool.
Prerequisites
- Your External IP Address
- A shared web hosting account that permits remote MySQL database access
- HeidiSQL installed on your local machine
- Database credentials (username and password)
- The remote MySQL server’s IP address or hostname
Find Your External IP Address
To find your external IP address, you can use a website such as https://www.whatismyip.com. Copy the IPv4 value.
Enable Remote Access
Log in to the shared web hosting account. The screenshot below is from MochaHost, but most shared web hosting companies should have a similar setup. Search for Remote MySQL and add the IP address from the previous step to this screen. When successfully added, it should appear in the list of IP addresses with remote access privileges.
Tip: You can optionally add a comment entry to differentiate various IP addresses.
Get Database Credentials (Host, Username and Password)
Search for MySQL database. Ideally you will find Remote MySQL Host information on this page.
Create a database user account to access the database remotely if you prefer not to use an existing account. Ensure the user is added to the database you wish to access and make note of the username and password.
Configure HeidiSQL
HeidiSQL is a free and open-source database administration tool for various databases, including MariaDB, MySQL, Microsoft SQL Server, PostgreSQL, and SQLite. You can download it from https://www.heidisql.com/download.php.
To connect to the remote MySQL database, follow these steps:
- Click the “New” button in HeidiSQL to create a new session
- Enter the ‘Remote MySQL Host’ value in the “Hostname / IP” field
- Enter your username and password in the respective “User” and “Password” fields
- Click “Save” to save the information
- To rename the session, right-click ‘Unnamed’ and select “Rename”. Enter a new name for the session.
- Click “Open” to establish a connection to the remote database
Conclusion
Connecting to a remote MySQL database using HeidiSQL is a straightforward process that allows you to efficiently manage your database hosted on a shared web host. Always remember to secure your credentials and use strong passwords for database access.
Now that you’ve learned how to connect to a remote MySQL database, you can start working with your data more effectively. Happy coding!