Hope you guys can help. I was working on my Craft site locally and now trying to upload it to the server but no matter what it says "Craft can’t connect to the database with the credentials in craft/config/db.php"
I have created the database in phpmyadmin along with the username and password.
Also my hosting provider is HostGator
This is what I have locally for the db.php
.
return array(
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
'server' => 'localhost',
// The name of the database to select.
'database' => 'simple-portfolio',
// The database username to connect with.
'user' => 'portfolio-rc',
// The database password to connect with.
'password' => 'r*****',
// The prefix to use when naming tables. This can be no more than 5 characters.
'tablePrefix' => 'craft',
);
And the server's db.php
.
return array(
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
'server' => 'localhost',
// The name of the database to select.
'database' => 'rchohan9_website',
// The database username to connect with.
'user' => 'rchohan9_portfol',
// The database password to connect with.
'password' => 'p************',
// The prefix to use when naming tables. This can be no more than 5 characters.
'tablePrefix' => 'craft',
);
Also the whole site is put in a folder so its not sitting in the root directory
Locally general.php
looks like this
return array(
'devMode' => true,
'siteUrl' => array(
'en' => 'http://localhost/portfolio',
),
'environmentVariables' => array(
'baseUrl' => 'http://localhost/portfolio/',
)
);
and on the server it's:
return array(
'devMode' => true,
'siteUrl' => array(
'en' => 'http://rachnachohan.ca/website',
),
'environmentVariables' => array(
'baseUrl' => 'http://rachnachohan.ca/website/',
)
);
I am completely out of ideas of why its not able to connect to the db.
die("Hello world");
statement to the appropriatedb.php
file, just above thereturn
statement, and refresh your browser – if the "Hello world" message displays, then you'll at least know that Craft is loading the correct config file. 2) The hostname, database name, username and/or password could be wrong. You should be able to confirm if the credentials are correct or not by logging in and out of phpMyAdmin.general.php
anddb.php
for your server and local environments; Craft makes it super easy to have different config values or different database credentials for multiple enviroments, all in the same file(s).die('hello world')
confirms the correct config file is being used, and I am able to login to phpMyAdmin using the exact same credentials indb.php
.