DNS - Accessing your Database before DNS change

From DreamHost
Jump to: navigation, search

Getting Started

(In the following article, items in bold are placeholder hostnames, and should be replaced with your own hostnames.)

To access your SQL database, you need a unique hostname (domain name) for your MySQL server. This can be any name you wish, so long as you have registered it, but it is commonly a sub-domain of "yourdomain.com" called "mysql.yourdomain.com". This arrangement is convenient to use with DreamHost's MySQL installations, as the servers can be created and managed all from within DreamHost Web Panel > Goodies > Manage MySQL.

However, during a server or host migration, the registration entries for "yourdomain.com" may not point to DreamHost's name servers, so you wouldn't be able to use a sub-domain of "yourdomain.com" for the MySQL hostname.

With DreamHost's setup, your MySQL server (which hosts all of your databases) is accessible from any domain or sub-domain that you assign to it. So you can still access your DreamHost-hosted MySQL database by assigning it a temporary subdomain which points to DreamHost. And that's easy to do.

Add a sub-domain

Add a free dreamhosters.com sub-domain at DreamHost Web Panel > Domains > Manage Domains > Add Domain / Sub-domain [1], scroll down to the "Mirrored" section, and create a mirror of "yourdomain.com" named "yourdomain.dreamhosters.com". Make sure to leave ".com" or ".net" out of the middle of this sub-domain name.

Add a MySQL hostname

Then add a hostname for your MySQL server to your new subdomain, with DreamHost Web Panel > Goodies > Manage MySql > Add New Hostname. Enter the hostname of your choice (commonly "mysql"), and select the new sub-domain using the dropdown menu.

So if your domain is "yourdomain.net" and your MySQL hostname is "mysql", your new sub-domain will be "yourdomain.dreamhosters.com" and the SQL hostname will be "mysql.yourdomain.dreamhosters.com".

Access the database with phpMyAdmin

Once the DNS changes propagate, you will be able to access the phpMyAdmin SQL management utility at "mysql.yourdomain.dreamhosters.com", using the SQL server login information you specified when you set up the MySQL server on the DreamHost panel. Or, assuming your sub-domain is up and running, you can access the admin app right away by pointing your browser to http://yourdomain.dreamhosters.com/dh_phpmyadmin/mysql.yourdomain.com.

If you try to access phpMyAdmin before the sub-domain's DNS records have changed, dreamhosters.com's phpMyAdmin interface will be unable to recognize your login information; this does not mean your installation is broken, just that DreamHost can't yet access your sub-domain.

See also DNS_-_Viewing_site_before_DNS_change

DreamPress

A caveat for DreamPress. Since you can't (easily) alias the MySQL server, you'll need to get your SQL server name from Panel > Goodies > MySql Databases. It looks like this:

MySQL Aliases

The important information is the name: wpsql1890xxx - You'll want to edit your wp-config.php file to make your MySQL hostname look like this:

 /** MySQL hostname */
 define('DB_HOST', 'wpsql1890xxx.dreamhostps.com');

Then your site will work fine.