Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MySQL Users problem.

Options
  • 25-10-2007 6:31pm
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,098 Mod ✭✭✭✭


    Hi, I am using php to connect to a mysql database for my webpage.
    Eg
    <?php
    $username = "Username";
    $password = "password";
    $hostname = "localhost";	
    $dbh = mysql_connect($hostname, $username, 
    
    $password) 
    	or die("Unable to connect to MySQL");
    print "Connected to MySQL";
    $selected = mysql_select_db("first_test",$dbh) 
    	or die("Could not select first_test");
    // you're going to do lots more here soon
    mysql_close($dbh);
    ?>
    
    Now this all works fine. I create a user with all priviledges, a database called first_test and it connects to the page fine.

    However, whenever I turn my computer off and on and try to log in as the user I created. It can not. I have to log in as root.
    So, for a user called 'me' I get this error,
    ERROR 1045 (28000): Access denied for user 'me'@'localhost' (using password: YES)
    
    So I can't connect to mysql. Anybody know what is up?
    Thanks.


Comments

  • Registered Users Posts: 7,411 ✭✭✭jmcc


    However, whenever I turn my computer off and on and try to log in as the user I created. It can not. I have to log in as root.
    So, for a user called 'me' I get this error,
    ERROR 1045 (28000): Access denied for user 'me'@'localhost' (using password: YES)
    
    So I can't connect to mysql. Anybody know what is up?
    What operating system (Windows/Linux)?

    Did you create the user with 'me@localhost' rather than 'me'@'localhost'?
    What privs did you give the user?

    What does the mysql.user table say?
    ( select host,user from mysql.user; )

    Can you log in from the command line?
    ( mysql first_test -uuser -p )

    Regards...jmcc


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,098 Mod ✭✭✭✭Tar.Aldarion


    jmcc wrote: »
    What operating system (Windows/Linux)?
    Windows
    Did you create the user with 'me@localhost' rather than 'me'@'localhost'?
    Nope
    What privs did you give the user?
    CREATE,INSERT,DELETE,UPDATE,SELECT
    What does the mysql.user table say?
    ( select host,user from mysql.user; )
    +
    +
    +
    | host | user |
    +
    +
    +
    | % | root |
    | localhost | me |
    | localhost | monty |
    | localhost | root |
    +
    +
    +
    4 rows in set (0.00 sec)
    Can you log in from the command line?
    ( mysql first_test -uuser -p )
    Regards...jmcc
    ah yes, it worked. It would not yesterday. I am using wamp and that only asks me for the root password, it won't let me select user unless I go from the cl. Can I change this?

    Thanks


Advertisement