Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-18-2012, 03:10 PM   PM User | #1
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Need help figuring out why I can't connect to MySQL

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?
Keleth is offline   Reply With Quote
Old 01-18-2012, 03:26 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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?
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 01-18-2012, 05:13 PM   PM User | #3
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
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.
Keleth is offline   Reply With Quote
Old 01-19-2012, 03:27 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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
PHP Code:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass'WHERE User='root';
FLUSH PRIVILEGES
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 01-19-2012, 04:01 PM   PM User | #5
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
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?
Keleth is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:00 PM.


Advertisement
Log in to turn off these ads.