Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

MySQL Users problem.

  • 25-10-2007 06:31PM
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,119 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, Registered Users 2 Posts: 8,201 ✭✭✭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

    Regards…jmcc



  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,119 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