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 trialElizabeth Fust
9,651 PointsError Establishing a Database Connection
I followed the instructions for using MAMP and installing WordPress, and I was able to work on a website in wordpress for a few hours yesterday. Today, I opened MAMP, clicked "open webstart page" then clicked "My Website." I got the error message "Error Establishing a Database Connection. I went back to MAMP page and clicked "Tools" and then "phpMyAdmin", I got an error that read, in part:
"phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server."
I opened wp-config.php, and the username is the same as I put in yesterday (per the video's instructions): wpuser. The password is the same password that I had generated randomly yesterday when I set it up.
I don't know what to do. Its so frustrating. I need to be working on my website.
1 Answer
Michele Smolensky
9,261 PointsPerhaps another spot to check for errors is where the document root in the MAMP settings is pointing to. You can find that by opening up MAMP > Preferences > Web Server and ensuring the file path under "document root" is pointing to the root folder of your project. Hopefully that helps!
Elizabeth Fust
9,651 PointsElizabeth Fust
9,651 PointsI looked at preferences, as Michelle suggested, and the document root was correct. I am using free MAMP, so I made the root htdocs (not "sites" as suggested in the video). The "localwp.dev," which is the name advised by the video, is in htdocs.
Let me also be more clear: When I open MAMP and click "open WebStart page", the page opens, and I click "My Website." Then a page opens that says: "Index of/" and there are three things that follow: MAMP-pro-logo.png, index2.php (renamed index.php per the video), and the newly created "localwp.dev". When I click "localwp.dev" (as I did during the video) it gives me the error "error establishing a database connection", even though on Sunday it worked fine.
Ugh. Maybe I should delete localwp.dev and start over again?