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

Development Tools Using PHP with MySQL Connecting PHP to MySQL Getting Started with PDO

Chris Martinez
Chris Martinez
11,715 Points

access denied

i keep getting this error:

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away' in C:\MAMP\htdocs\database.php:5 Stack trace: #0 C:\MAMP\htdocs\database.php(5): PDO->__construct('mysql:host=loca...', 'root', 'root') #1 {main} thrown in C:\MAMP\htdocs\database.php on line 5

ive tried leaving off the password, tried listing and not listing my port, and i dont understand half the jargon some of these answers.

This isn't really a problem with your connection details.

From the MySQL reference:

The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.

Has MySQL definitely started properly? Has MySQL worked properly in the past for you?

I recently tried to get MAMP working on my windows machine and ended up going back to WAMP Server

1 Answer

Chris Martinez
Chris Martinez
11,715 Points

I figured this one out the next day. Amazing what a little rest will do for problem solving. I was not writing in the correct port number for mysql: i was using the number for apache!