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

shareyourpeace
shareyourpeace
3,244 Points

Wordpress Development Track. MAMP. Error establishing a database connection.

MAC . Wordpress Development track. ' Error establishing a database connection. ' I am following the video exactly.

MAMP control panel shows apache port: 80, MySQL port: 3306

When I type in the URL field: localhost I get Index of / Localwp.com Test site.com

Like in the video.

Localhost.com has all of the wordpress files.

Note. Prior to this, I had to use Terminal and the following command because from the MAMP Control Panel, MySQL server would not turn green.

Sudo /usr/local/MySQL/support-files/MySQL.server stop

This must have been causing a conflict with the MAMP (GUI) that I installed with the course because then from the MAMP control panel, MySQL server DID turn green.

All of that and I am stuck. Anyone know what I need to do? Thanks,

4 Answers

shareyourpeace
shareyourpeace
3,244 Points

Resolution and explanation. Below are two problems, related, that I resolved. I hope this clarifies things for others.

1. MAMP = Mac. Apache(server) mysql(database). PhpMyAdmin.

On a Mac running Mountain Lion (different from previous OS), I had installed MAMP MANUALLY. This required a few steps from the command line to start Apache and then to install/configure MySQL and phpMyAdmin. This was done several months earlier.

From the Wordpress Development Track-Course, Zac demonstrates using a DIFFERENT installation of MAMP. The difference is that you end up with a GUI (graphical user interface) of MAMP which provides a control panel. There you can start and stop Apache Server and MySQL server. You can change the ports. This MAMP install is visible in the Applications folder (from the finder).

The PORT configuration. That was part of the problem. My manual installation of MAMP was configured to use the same PORT as the GUI install. This created a CONFLICT.

I had to run commands from Terminal on the Mac. I had to Stop Apache Server from the command line. I had to Stop Mysql Server from the command line.

Then when I clicked on the icon in the dock (I put it into the dock) To launch MAMP, both servers turned green light. It took a little bit for the MySQL to turn green.

  1. In the tutorial, we came to this. In the URL field type: 'localhost' It returned: Index of Localwp.com ( the folder we created. The wordpress files live there)

In the tutorial, when Zac clicked on that link, it opened a page to CONFIGURE Wordpress. I kept getting the following Error. 'Error connecting to the database'.

After much troubleshooting, decided to download a Fresh version of wordpress. I noticed something when I compared my Old version of wordpress to this Fresh version of wordpress The old folder had two files: Wp-config-sample.php Wp-config.php

The Fresh version Only had Wp-config-sample.php

I deleted the Old version and copied the new version into the Localwp.com folder

Returning to the URL Localhost Brought back up Index of Localwp.com

When I clicked on the localwp.com link It CONNECTED me to the database.

Conclusion (in my humble opinion). I had corrupted the created wp-config.php file. When I started Fresh, The process used the wp-config-sample.php file and Recreated the wp-config.php file

I examined both files in my text editor. The wp-config-sample.php had defaults. I could visual see in wp-config,php had settings that I entered for database, user, password, host were what I entered .

I hope this is clear.

shareyourpeace
shareyourpeace
3,244 Points

Resolved.

Remotely. I had created the 'database' localwp. I had created the 'user'. wpuser.

I had NOT added the user to the database. This fixed the error.

Noah Laurent
Noah Laurent
3,080 Points

WOW, that was a straight forward piece of advice.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi!

Do you have MAMP properly up and running now that it's being manager by the MAMP GUI? I was unclear what your question was..

shareyourpeace
shareyourpeace
3,244 Points

Hi Zac.
I cannot proceed from this point. You say, go your your localhost and click on 'localwp.com' ( this is where I copied all of the wordpress files)

"Error establishing a database connection."

Yes. MAMP is running. Both apache server and MySQL server have green lights in the MAMP control panel.

Tab Settings:

Preferences > ports Apache: 80 Nginx :80 MySQL: 3306

WebServer (apache must have been the previous install) Apache radio button chosen. Document root: mycomputer > Sites

'Open start page ' brings me to localhost/MAMP/

Following you in the video, I created the database:localwp And the user: wpuser

I made up my own password.

The other day when I was following this before i had problems, I actually did get to the screen where it says,

"Create a configuration file"

Thanks for helping.