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.
Jun XIE10,363 Points
can not connect to the database and shows access forbidden
In the video"getting started with PDO", I typed "<?php $db = new PDO("mysql:host=localhost;dbname=shirts4mike;port=3306","root",""); var_dump($db); ?> as it instructs. I opened the database.php file in the browser, but it shows "Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server.". Then I checked in terminal that the port is 3306 and the password is blank, they are no problem. I also can access shirts4mike in terminal. I don't know if someone has met the same situation. If so, could you please help me with it? :P. Thanks in advance!
Philip Cox14,818 Points
Hi Jun. As Randy mentions, you may not need to add the port number, I didn't. Try some variations, drop the port number and just use the user name and password, root, root. Also, you have MAMP or WAMP running I take it?