Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

WordPress install not working

HI,

So I got this:

Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or we canโ€™t contact the database server at localhost. This could mean your hostโ€™s database server is down.

Are you sure you have the correct username and password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? If youโ€™re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

I'm on windows 10. I use MAMP PRO and i got it it set up. I went to phpmyadmin, and i created new database and a user on local host.

I even went and tried to put the info in config-sample and changed it to config etc.

I tried all i could think of.

Doesn't work.

3 Answers

Daniel Stopka
Daniel Stopka
13,520 Points

Hi,

most times there are mistakes in creating database user and assigning him to the right database in MySQL admin... also the user has to have all privileges set... Most of type default user name and password 'root' should work...

Also DB_HOST should be localhost...

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

I did create a lot of new databases and i assigned it multiple times , and I checked it a thousand times. Everything , the privileges are set . Root, or not, i checked that as well.

Db host is localhost.

It doesn't work.

Kevin Korte
Kevin Korte
28,149 Points

Daniel is right, check, and keep checking. Make sure your db user has privileges to the database. It does work, you are just not giving wp the correct db credentials to set up.

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

I checked it now for the million time. This isn't also my first time setting up a wordpress site, though it its on windows, it that has any meaning.

It just doesn't work. I checked up my database, created new database, checked my details, and it would even work with root, it don't even need to add new user, but i did both ways. I even changed it in my config file manually, it doesn't work.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Just out of curiosity, are you absolutely positive that the MAMP services are running? It's possible that even though you've installed them (and even started them) that something else has stopped or paused the services.

Kevin Korte
Kevin Korte
28,149 Points

Okay, than follow Jennifer's advice, and than back track your steps and try again for the 1,000,001 time. I know you've set wordpress up before, but I can assure you it's not wordpress, it something on your end.

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

Hi Jennifer,

I'm absolutely sure that MAMP services are running. It's green : Apache and MySQL is green.

I get the same message , error estabilishing connection if I do it manually, and if i do it with wordpress files it's the same.

I did install a new wordpress fie, and created new user, and new tab in MAMP, and it's still the same result.

Though I did create a static site now, just to test it out again, and the static site worked lol though WP didn't work.

I have set it on port 8888. I don't know what else to do.

Daniel Stopka
Daniel Stopka
13,520 Points

WP can create wp-config for you, but if something is not working, then I think that it is always good idea to try another approach... How did you exactly write this line with letters?

define('DB_HOST', '127.0.0.1');

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

define('DB_HOST', 'localhost');

Daniel Stopka
Daniel Stopka
13,520 Points

Can you login to phpmyadmin using your login and password written in wp-config? If yes, can you send us your wp-config file...

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

WordPress should do the wp-config file for me. I shoudn't be going there and do it manually in the first place.

Though sure.

And like I said before, username, and password, I did actually generate the password, as well as put my own, and i did put a username before. But this was my last test too.

In DB Host, i checked both ways, writing numbers and with letters.

define('DB_NAME', 'wp_myblog');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'root');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Kevin Korte
Kevin Korte
28,149 Points

There is value in knowing if you're able to log in to phpmyadmin with the same credentials you're giving wordpress, so I wouldn't dismiss this idea so fast Aurelian. If you can, at least you know your credentials are find, and it means that it can't find your database. If it can't than you need to double check your credentials, and their permissions.

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

So I'm lost now. This is local WP theme development. I don't have any password to log in to phpmyadmin. I have just installed MAMP, and i just wanted to do WP theme.

Unless you mean when I add a new user? I'm not sure what you mean by 100% now.

Kevin Korte
Kevin Korte
28,149 Points

Right, does your database user, the one you give WP, have full access rights, you can test that by trying to use those credentials on making changes to the database.

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

It said that password and login is ok, but it can't find the database once I tried yet again..