SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    ff
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php mysql connection problem

    Hello, friends

    Im beginner in php mysql.

    My setup is windows xp , apache 2 , php 4.3.10 , mysql 4.1.8 ...
    Php and apache work fine , and i can control mysql via command line .

    But ...

    When i try to control mysql via php with the follow script :

    <?php
    $connection = mysql_connect ( "localhost", "root", "") or die ( "unable to connect to MySQL" );
    echo( "connected to MySQL" );
    ?>


    I take the next message :

    Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\Sites\Testa\in.php on line 9
    unable to connect to MySQL

    Help me friends
    Thanks

  2. #2
    SitePoint Addict trogdor1024's Avatar
    Join Date
    Oct 2004
    Location
    New Jersey
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm assuming that you haven't set up a mysql password for root? Because you're not passing it if you have set it up. Also, make sure that "root" is valid a mysql user (within the "mysql" database). It may also be complaining about the "localhost".

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe that is a problem in case above. But I also installed similar configuration and get same error. And I'm sure I've set up my root password. Also, I checked users in database.
    What can be another problem?

  4. #4
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you heard about reseting root password?

    what trogdor1024 said was true. First of all, before you post a question, maybe try reading readmes and install.txts. no offense

    hehe..

    now go to the command line and access mysql, since you said, you can connect to it, right? now open your help file, from mysql folder, in docs. look for reseting password in file mysql_toc.html

    then follow the instructions on how to reset the root password. that should do the trick.

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I've got the same problem

    I have already posted for this problem and had no response
    as I was reading noticed this lot of similar problems
    I have done all I can think of
    and still cant get access to database from php
    however I can login from the command prompt just fine
    someone must know the answer
    cant progress without getting access to this server
    regards Ron

    i got this error message
    Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    i used this connect string

    <?php

    $link = mysql_connect('localhost', 'root', 'james2');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>
    Last edited by ronkirby; Feb 12, 2005 at 02:06. Reason: got some more info

  6. #6
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See the URL for an answer on "does not support authentication protocol" error.
    http://forums.devshed.com/t206848/s.html

    Perhaps we should have a similar sticky on this site moderators? This item crops up a lot.


Bookmarks

Posting Permissions

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