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

MySQL --- Access DENIED !!

I am very confused! Ever since starting the course Using PHP with MySQL I've had nothing but trouble with my localhost & databases. I'm on the PHP Development and have installed both XAMPP and MySQL Workbench on my Windows 8 system. My experience in any of this is strictly limited to what I've received on this track.

Anyway, my problem seems to be conflicts between XAMPP and MySQL. I was required to create a password during the MySQL setup. Now I'm being denied access 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)' in C:\xampp\htdocs\database.php It says (using password: YES) but the Users Overview of phpMyAdmin panel says No Password is set.

I feel like I'm burning out here, and trying to put together this call for help is making it harder to keep my eyes from getting crossed.

I found this in a forum somewhere and managed a try

Try to login via the terminal using the following command:
mysql -u root -p
It will then prompt for your password. If this fails, then definitely the username or password is incorrect.

and I got

ERROR 1045 <28000>: Access denied for user 'root'@'localhost' <using password: YES>

so... I guess the only intelligible question I can manage is how can I - or, CAN I - get these two programs to agree with eachother and get along with me at the same time??!

3 Answers

I've even tried uninstalling / reinstalling both XAMPP and MySQL Workbench, but it hasn't helped.

  1. I'm currently being denied access to my database,

  2. there is a conflict somewhere about whether or not 'root'@'localhost' DOES or DOES NOT have a password.

  3. phpMyAdmin (XAMPP) says NO password is is set, but in the terminal it says <using password: YES>

I've been trying to uninstall everything related to MySQL Workbench, but MySQL for Visual Studio 1.2.3 will not finish uninstalling off my system.

I'm sure I've left out information that would help those that are apt to troubleshoot & resolve the issue I'm having, but please bear with me & I'll do the best I can to fill in the blanks. I'm feeling desperate to solve this rather serious problem.

ThankYou!

So, the problem persists! in phpMyAdmin (accessed via the XAMPP Control Panel, Module: MySQL, Admin) it says NO PASSWORDS are set, but when I type localhost/database.php into my browser the FATAL ERROR says <password YES> like this

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)' in C:\xampp\htdocs\database.php:3 Stack trace: #0 C:\xampp\htdocs\database.php(3): PDO->__construct('mysql:host=loca...', 'root', 'root') #1 {main} thrown in C:\xampp\htdocs\database.php on line 3

here is what the database.php file looks like (as per the earliest part of Randy's course Using PHP with MySQL)

<?php

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

Here, the second "root" is supposed to be the PASSWORD, if it is not set (if I'm understanding correctly). But here, I have also replaced it with the password I "set" when I was installing MySQL Workbench, which also showed the same FATAL ERROR.

I'm being told that USER and PASSWORD are not correct, and I need to figure how to set them back to DEFAULT!

Has anyone else ever had a CONFLICT like this trying to access the 'root'@'localhost' database while having XAMPP and MySQL Workbench installed simultaneously? (note that I was aware to have one server running at a time, and that currently I have UN-Installed MySQL Workbench hoping to resolve the user/password conflict: yet, ACCESS still DENIED)

I Thank Everyone for your Patience, and I'm Cautiously HOPING to learn the right answer!

Thank You Franklin, but that link doesn't help much. That post was in reference to Apple machines, I'm using Windows 8.