PHP Mysql error

Discussion in 'PHP' started by sindhmojood, Jul 22, 2010.

  1. #1
    i wrote

    <?php
    mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
    echo "Connected to MySQL<br />";
    ?>
    i found error

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in C:\wamp\www\s\c1.php on line 10
    Access denied for user 'admin'@'localhost' (using password: YES

    I am very new in PHP Mysql
     
    sindhmojood, Jul 22, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    means wrong user and/or password
     
    gapz101, Jul 22, 2010 IP
  3. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This can mean quite a few things... the most common cause is that you have the wrong password.
     
    Deacalion, Jul 22, 2010 IP
  4. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #4
    default would be username Root with no password, but the error suggests that you edited the config file within the phpmyadmin program, did you do that ?
     
    MyVodaFone, Jul 22, 2010 IP
  5. ModDish

    ModDish Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    are you sure you edited your mysql un and pass to be admin and 1admin ?
     
    ModDish, Jul 22, 2010 IP
  6. azwan2u

    azwan2u Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe no user 'admin' exist,
    or wrong password.

    Better check again.
     
    azwan2u, Jul 22, 2010 IP
  7. avenir

    avenir Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    maybe you shoud GRANT admin user in mysql like this:

    > GRANT ALL on yourdb.* to admin@localhost identified by '1admin';
     
    avenir, Jul 22, 2010 IP
  8. sindhmojood

    sindhmojood Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yes i edited password

    yes i sure
     
    Last edited: Jul 26, 2010
    sindhmojood, Jul 26, 2010 IP
  9. manzar

    manzar Peon

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    use this code and change 'type password here' and give correct password or if you use simple wamp server than ('localhost','root','') use

    <?php
    mysql_connect('localhost','root','type password here') or die('Not connected to server');

    mysql_select_db('databasename') or die("NOT selected DB");

    ?>
     
    manzar, Jul 27, 2010 IP
  10. sandy_joy

    sandy_joy Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi, I suggest you that if you are new then you use Just like that,
    <?php
    $connection = mysql_connect("localhost", "root", " ") or die(mysql_error());
    ?>
    Because here we use all Parameter which is consider as a Default, but if you want to run your own code then, first you go Privilege,in PHPMYAdmin section[MySql Section], here you have an Authority that, You create a new user as you want to do
    later you try and get you Success with your native code.

    <?php
    mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
    echo "Connected to MySQL<br />";
    ?>
     
    sandy_joy, Jul 27, 2010 IP