Conrad Reeves
Conrad Reeves

Reputation: 78

Find the Web Address for MySQL Database

I have got a cPanel hosting and I can create and log in to the phpmyadmin and change databases after I log in to the cPanel. What I need to do is log in to the same database even if my files are not on the same server, so I need to specify the exact database URL instead of "localhost". How do I get that URL?

Upvotes: 0

Views: 4572

Answers (1)

Ralph Ritoch
Ralph Ritoch

Reputation: 3440

The most secure way to access a remote database server is to setup SSH access on your database server and a SSH Tunnel on the web server that is hosting your files.

See: Connect to a MySQL server over SSH in PHP

This way you don't need to expose your database server to the internet, and instead can access it from the localhost of your web server.

If the database is exposed to the internet, you can assign a domain name to your database server and use that domain name, or subdomain, as the host and create a wildcard user like root@'%' but that is far less secure.

Upvotes: 1

Related Questions