Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!