For your MySQL database to work properly, you must be able to connect to MySQL. This requires a script to contact the database for the information it contains.
Note that not all script configuration files for everything is located in the same place. For instance the one for Joomla is in the /configuration.php path, the one for WordPress is at /wp-config.php while the one for Moodle is at /config.php
What to look out for? The access information should look like:
Host Name = localhost (literally input localhost)
Database Name = cpanelUsername_databaseName
Database Username = cpanelUsername_databaseUsername
Database Password = what your password is
Let’s say your username is John, the database Name is wrdp1, the database-Username is wp1 and the Database-User Password is pizza. Host name will always be localhost.
For WordPress, as an example, it should look like this:
// ** MySQL Settings ** //
/** The name of the database for WordPress */
/** MySQL database username */
define(‘DB_USER’, ‘ John_wp1’);
/** MySQL database password */
/** MySQL hostname */
Although you can connect to the database using your cPanel username and password, this is strongly discouraged. This is because whenever you change or reset your cPanel password your databases will stop working until the configuration files are updated.
If you are on a shared server, the database user name cannot be changed to something without the cPanel user’s name in it.
How to connect to MySQL Database remotely
All IPs are blocked from the MySQL database by default. You must add them to an access list so you can access the server. Before connecting to MySQL from another computer you must also be sure the connecting computer is enabled as an access host.
To do this you might need a MySQL client like Navicat, Dreamweaver, phpMyAdmin or Workbench. You also need to know ahead what your IP address is, if you don’t know then go to whatismyip.com.
Your configuration should look like this:
Host name = (use the server IP address)
Database name = (cpanelUsername_databaseName)
Database username = (cpanelUsername_databaseUsername)
Database password = (the password you entered for that database user)
MySQL Connection Port = (what number your connection port is)
Note that if you are connecting from an IP address that can change periodically you can use % as the wildcard value. However, this is not recommended as this will grant access from anywhere. You must also have to update the connecting IP to remotely access MySQL whenever it changes.
If you are using cPanel X3 the operation should still be the same. However, the cPanel X theme will have the MySQL Database icon in the Database section instead of the Remote MySQL icon. The operations is still pretty much the same, you just have to scroll down all the way to the bottom to get to the field where you have to input your IP address.