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

Chris Martinez
Chris Martinez
11,713 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,713 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!