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

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".