Multi-Environment Config Database Credentials
Here is what my configuration looks like. Ideally, I'd like to swap out the hard-coded baseUrl with something like I have for basePath. That way the other members on my team can call/put the site wherever they want and it won't break anything.

I don't make any changes to index.php.

Hope this helps!

db.php

return array(
'*' =&gt; array(
    'tablePrefix' =&gt; ''
),
'.dev' =&gt; array(
    'server' =&gt; 'localhost',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
),
'mysite.stagingdomain.com' =&gt; array(
    'server' =&gt; '12.345.67.890',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
),
'mysite.com' =&gt; array(
    'server' =&gt; '12.345.67.890',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
)


);

general.php

return array(
    '*' =&gt; array(
    'cpTrigger' =&gt; 'admin',  // whatever you want
    'omitScriptNameInUrls' =&gt; true,
    'enableCsrfProtection' =&gt; true
),
'.dev' =&gt; array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; 'http://mysite.dev/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://mysite.dev/', 
    )
),
'mysite.stagingdomain.com' =&gt; array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; 'http://mysite.stagingdomain.com/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://mysite.stagingdomain.com/'
    )
),
'mysite.com' =&gt; array(
    'siteUrl' =&gt; 'http://www.mysite.com/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://www.mysite.com/'
        )
    )
);