Sites that run on this hosting account should keep using localhost. You only need remote access when something outside the account must talk to the database: a tool on your computer, an app on another server, or a reporting system.
Shared hosting databases are MariaDB. cPanel still labels the tools MySQL. Need the database first? Create a MySQL database and user.
Open cPanel
- Sign in at the portal.
- Open the hosting service for the site.
- Click Log in to cPanel.
You do not need a server hostname to get in.
Add the remote host
- In the Databases section, open Remote MySQL. Some cPanel themes call this Remote Database Access.
- Under Add Access Host, enter the public IP address of the machine that will connect.
- Click Add Host.
- Confirm the IP appears in the Access Hosts list.
Use the exact public IP of the connecting machine. Prefer that over a wildcard.
- A single IPv4 address is the usual choice, for example
203.0.113.10. - If that machine uses a small, stable range, you can use
%as a wildcard in one octet, for example203.0.113.%. %on its own allows any host. Do not use that unless you understand the risk.
To remove access later, delete that host from the same list.
Check the database user
- Open MySQL Databases.
- Confirm the user is assigned to the database you want to reach.
- If the user existed before you added the access host, add the user to the database again so privileges refresh.
cPanel prefixes both the database name and the username with your account name. Use the full values shown in the list.
Connection details for the remote app
On Remote MySQL, or in the cPanel sidebar under General Information, note the hostname or Shared IP Address. Put that in the app as the database host. Do not use localhost. Do not guess a server name, and do not use your public website domain (extra DNS can send the connection to the wrong place).
| Setting | Value |
|---|---|
| Host | Hostname or Shared IP from cPanel (not localhost) |
| Port | 3306 |
| Username | Full database username, including the prefix |
| Password | The password you set for that database user |
| Database | Full database name, including the prefix |
That password is not your portal password, and it is not the cPanel owner password unless you set them the same.
For a site that already lives on this account, including WordPress installed with WordPress Toolkit or Installatron, leave the host as localhost. See Fix "Error Establishing a Database Connection" in WordPress if the site on this account cannot reach its own database.
Tips
- Add only the IPs you need. You can add more than one host.
- If the connecting machine has a changing IP, add the new address when it changes. Do not leave
%in place as a shortcut unless you accept that anyone who has the password can try to connect. - Browse and edit the database in the browser with phpMyAdmin. That does not require remote access.
- Prefer a strong, unique password on the database user. Grant only the privileges the app needs.
If the connection fails
Work through this list, then open a support ticket if it still will not connect. Include the IP you added and the hostname you used (not the password).
- The access host is in the Remote MySQL list and matches the connecting machine's public IP.
- You are using the full username and database name, not the short names you typed when creating them.
- The host in the app is the cPanel hostname or Shared IP, not
localhost. - The port is
3306.
We will check the account and help you get the connection working.