Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts

    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?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •