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.

PHP

Nthulane Makgato
PLUS
Nthulane Makgato
Courses Plus Student 19,602 Points

How does one check database credentials in Mysql?

I'm watching a video on connecting PHP with MySQL and on one of the first few videos they test connection with the database. So after opening a script(database of Shirts4Mike) in MySQL and executing it, create a document in htdocs called database.php and write the following line of code on it:

<?php

$db = new PDO("mysql:host=localhost;dbname=shirts4mike;port=8889","root","root");
var_dump($db);

Then run "localhost/database.php" in the browser and following should show:

object(PDO)#1 (0){}

if not, there must have been a problem connecting the database. I don't get this response. I have checked that both MAMP and MySQL servers are running.

How do i check if my credentials are correct?

Thanks!

2 Answers

Logan R
Logan R
22,989 Points

Try going to the url "localhost/phpmyadmin" and try your information there.

If I'm not mistaken, default username is "root" and default password is blank.

Nthulane Makgato
Nthulane Makgato
Courses Plus Student 19,602 Points

You were right. Redid it using phpmyadmin and its working.

Nthulane Makgato
PLUS
Nthulane Makgato
Courses Plus Student 19,602 Points

I doesn't work. The problem with this is that I executed the database in MySQL, not "phpmyadmin".