Allow External MySQL connections

samarudge

Registered
Sep 29, 2010
1
0
51
I'm trying to connect to a database on a server running CPanel from my desktop. When I try to connect I get the error
Code:
Warning: mysql_connect(): Host 'my.hostname.here' is not allowed to connect to this MySQL server
How do I allow hosts to connect to the server? I have access to CPanel and WHM but not root SSH.
-Sam
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
23
143
Houston, TX
cPanel Access Level
Root Administrator
grant to [email protected]

You will need to grant access to the user at your desktop system's IP address. Currently, access will be granted only to the user at either localhost, 127.0.0.1, or the server's hostname.

The basic syntax would be like this:

Code:
GRANT ALL ON mydb.* TO 'someuser'@'somehost';
Where mydb would be your database name, someuser would be the user that already has access to the database, and somehost is your desktop's IP address. You can verify the public IP address that the server will "see" from your desktop by browsing http://www.cpanel.net/apps/myip/.

You can enter this either at the MySQL CLI command prompt or in phpMyAdmin.

I recommend the following section of the MySQL manual, which explains the GRANT command in detail:

MySQL :: MySQL 5.1 Reference Manual :: 12.4.1.3 GRANT Syntax