Can I connect remotely to MySQL database?

Yes! it is possible. For this you have to allow remote access from your control panel, by adding your IP to the access hosts in mysql screen there. If you do not have a fix IP at your end you can use % as wild card and allow remote access from anywhere.

Then for remote connection you have to use the server IP or your domain IP or domain name instead of localhost in your script/program.

For example, to connect remotely via mysql command line utility:

mysql -h x.x.x.x -u USERNAME -p DATABASE

(where x.x.x.x is your server ip, USERNAME is the db user, and DATABASE is the database name)

NOTE: Whenever an IP/Host is added or removed from the Access Host field, the privileges need to be reassigned to the database user on that database otherwise it will produce Access Denied error.

Was this answer helpful?

 Print this Article

Also Read

Can I import csv files using Load Data Infile?

This feature is not supported by cpanel but you can ask support to add File_priv to your db user...

Why do I get error message: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' on shell?

If you get this error message when trying to use mysql command line utility from shell: Can't...

phpMyAdmin

phpMyAdmin is a third-party tool included with cPanel, used for maniuplating MySQL databases...

MySQL Database Wizard

cPanel can guide you through the process of setting up a MySQL database, along with the...

How do I connect to and use MySQL?

Please login to your control panel and follow these steps to create the database, user and its...