View Full Version : Need help figuring out why I can't connect to MySQL

01-18-2012, 04:10 PM
If this isn't the right forum for it, I'd appreciate if an admin could move this.

I recently installed the latest WAMPserver onto my work laptop, got it up, and tried to start developing. I can connect to MySQL through the phpMyAdmin that comes with the server, but when I try to connect through my code, it fails.

I've tried connecting both through PHP's PDO as well as through mysql_connect, and in both cases, it says access denied for the user. I've tried removing the password, putting it back simpler, etc, and nothing seems to change. I have no idea how to diagnose where the issue is. Can someone lend a hand?

01-18-2012, 04:26 PM
Well you need to find out what the login for PHPMyAdmin is, it will be the same for your php. What username are you using for your mysql_connect call?

Do you have to put in a username and password for PHPMyAdmin or does it just work?

01-18-2012, 06:13 PM
The phpMyAdmin came preconfigured and just works when I go to it (localhost/phpmyadmin).

For the mysql_connect, I tried both a username/pass I setup, as well as root with no password. Neither had any luck.

01-19-2012, 04:27 AM
Okay in the phpmyadmin directory on your pc look for a file called config.inc.php, open it in notepad or editor of your choice. This should at least have your username in it. As for the password there is a way to reset it. You can run this query in phpmyadmin

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

01-19-2012, 05:01 PM
So this morning, for whatever reason, root with no password worked, so I tried changing the host of my user from '%' to 'localhost', and it worked. I have no idea why it previously failed, or what about it is different. In fact, at home I'm using an older version of WAMP (thusly an older version of PHP/MySQL) in which I use '%' for local users with no problem.

Anyway, thanks for helping point me in the right direction.

One more thing, on a slightly related note... I remember when I first tried using WAMP2, I believe had the issue of password that was too long. Do you happen to know how I can check what the max length of a password is, and how to change that?