WEB HOSTING

How to connect to a remote MySQL database in cPanel

MySQL is an open-source relational database management system. Like other relational databases, MySQL stores data in tables consisting of rows and columns. Users can define, manipulate, control, and query data using the structured query language, more commonly known as SQL.

To connect to a MySQL database remotely from your local system, your cPanel hosting provides the Remote MySQL tool, which allows you to connect remotely to your database. This feature enables remote hosts to access the databases on your account.

Allow a remote connection to a MySQL database

Before you can connect remotely to your databases, the IP address used for remote connections must be authorized on your account side. To authorize a remote connection, please follow these steps:
Access your cPanel account

Go to the Remote MySQL menu in the Databases section.

Remote MySQL
On the next page, enter the domain name or IP address of the server hosting the web application. You can add a wildcard character (%) to allow multiple IP addresses to access the database; for example, 192.68.0%. When using a wildcard character, make sure to limit the scope to addresses under your control or those you are sure are secure.

Comment (optional): To remember the entry, you can write a note.

MySQL host
To save the configuration, click the Add Host button.

Next, you need to configure your site to use the remote database. The process differs depending on the application. For example, on a newly installed WordPress site, you first need to create the database in the cPanel MySQL database wizard.

Then, modify the wpconfig.php file of the WordPress site to include the database name and authentication credentials, along with the domain name or IP address of the server.

define( ‘DB_NAME’, ‘wp_database’ );

define( ‘DB_USER’, ‘user’ );

define( ‘DB_PASSWORD’, ‘a-secure-password’ );

define( ‘DB_HOST’, ‘203.0.113.0’ );

Connect to a MySQL database remotely

After enabling host access, you can remotely connect to your MySQL databases using a MySQL client application. For example, MySQL Workbench is an integrated toolset that allows you to manage databases, run queries, and much more. MySQL Workbench can be downloaded and used for free. Versions are available for Microsoft Windows, Mac OS X, Linux, and other operating systems.
To establish a remote connection to your database using MySQL Workbench, follow this guide

Articles Liés