Why can't I connect to my database?

This FAQ was last modified on: Thursday, September 1, 2016 12:37pm
Category: 

Once you've imported or created your database you need to tell PHP where that database is. On Metro (the old hosting server) the database server and web server were on the same host. So while your mysql_connect string on Metro might have looked like this:

          $link = mysql_connect("localhost", $username, $password);

on WebHosting you need to specify your server as "mysql.localhost", like this:

          $link = mysql_connect("mysql.localhost", $username, $password);

 

mysql.localhost is a host alias on the webserver to another machine.  You may have it set as web-dbN.gatech.edu where N is the web-pleskN.gatech.edu machine on your site.  We reccomend that you do not use this older convention as it breaks our ability to quickly and transparently migrate your site to more robust hosting servers.  One important point to remember is that mysql.local is only accessible from the WebHosting server(s). If you need to connect directly to the database you should use an SSH tunnel.