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 14 of 14
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Error 1045 (28000)

    Hi,

    I am learning MySQL and have created a user, granting all privileges on a database "publications". After i have created the user, when i go to log in with the username and password i get the Error 1045 message. Here is the code, i would appreciate any help with the issue.

    I am certain it is not a typing error.

    Code:
    mysql> GRANT ALL ON publications.* TO 'user1' IDENTIFIED BY 'mypswrd';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> quit
    Bye
    
    C:\Documents and Settings\Owner>"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql" -u user1 -p
    Enter password: *******
    ERROR 1045 (28000): Access denied for user 'user1'@'localhost' (using password: YES)
    
    C:\Documents and Settings\Owner>"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql" -u user1 -p
    Enter password: *******
    ERROR 1045 (28000): Access denied for user 'user1'@'localhost' (using password: YES)
    
    C:\Documents and Settings\Owner>

  • #2
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts
    bump.

    Anyone got any ideas

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,026
    Thanks
    23
    Thanked 588 Times in 587 Posts
    This my be all wrong because I learned Mysql through php not the command line but I think you make a use with 'user1'@'localhost' or 'user1'@'%'

    See this page of manual:

    http://dev.mysql.com/doc/refman/5.1/...ing-users.html

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Correct, Sunfighter. Unless you *want* to be restrictive, I recommend using 'username'@'%'
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Thanks for the replies but i'm still not getting anywhere with either of those two methods. When i look in phpMyAdmin the user account is created, password-protected and assigned the privileges that i assigned it; but i can't log into the account from the command line with the password.

    Strangely, i can log in to mysql as user1 without giving a password. I can only assume this will give me limited privileges. That's beside the point anyway - i need a way to remedy this; this is one of those fundamental things i need to get out of the way before i can't continue learning more about mysql.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Well, I don't pretend to understand why, but I had the same problem.

    But when I then changed to use
    Code:
     grant all on test.* to 'foo'@'localhost' identified by 'bar';
    it worked fine. I'd swear I had used @'%' before, but... Whatever works.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    LMAO!

    Code:
     grant all on test.* to 'foo'@'*' identified by 'bar';
    WORKED!

    Using * instead of %

    GO figure.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts
    I'm sorry to be a pain in the *** but i'm still getting nowhere. The suggestion directly above didn't work for me either.

    Just to make it clear, i am able to create the user and assign a password - this user then shows up in phpMyAdmin saying "password-protected: yes". So i'm assuming that the actual creation of the user has gone fine.

    When i try to log in with:

    Code:
    C:\Documents and Settings\Owner>"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql" -u user1 -p
    Enter password: *******
    i get the ERROR 1045 message. I can, however, log into user1 if i leave out "-p". It just goes straight to mysql without requesting the password. I don't know if this is normal procedure or not though.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I can't tell you what the difference is in your DB vs. mine. I certainly can't "log on" to user foo in my DB if I don't supply a password.

    I get the Error 1045 if I simply use mysql -ufoo

    On the other hand, if I use mysql -ufoo -pbar then it works like a charm.

    Here are the actual steps, as I performed them:

    Code:
    c:\> mysql -uroot -p*****
    
    mysql> grant all on test.* to 'foo'@'*' identified by 'bar';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> quit
    
    c:\> mysql -ufoo -pbar
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | test               |
    +--------------------+
    2 rows in set (0.01 sec)
    
    ...
    And, yes, there are several other databases on this server. All visible to root but not to foo

    Why it should be different for you, I am utterly at a loss. FWIW, I am using MySQL version 5.5.8, Community edition.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Thanks for persisting; i tried again exactly as you typed above but again with no luck. Is it possible there is some subtle syntax error in my code that i'm missing; like inverted commas in the wrong place or something similar?

    I am also using 5.5.8

    Code:
    C:\Documents and Settings\Owner>"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql" -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 28
    Server version: 5.5.8-log MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> GRANT ALL ON test.* TO 'foo'@'*' IDENTIFIED BY 'bar';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> quit
    Bye
    
    C:\Documents and Settings\Owner>"C:\wamp\bin\mysql\mysql5.5.8\bin\mysql" -ufoo -pbar
    ERROR 1045 (28000): Access denied for user 'foo'@'localhost' (using password: YES)
    
    C:\Documents and Settings\Owner>

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    That is just too bizarre for words.

    Heck, we are even using the same directory (well, almost...mine says "Bill" instead of "Owner", but the point is that we clearly aren't using any special setup).

    The only thing I see different is that my "root" user was installed to require a password, but I can't see why that would matter, since in either case this *IS* "root" doing the grant.

    Oh...and I added the path to the mysql executable to my windows PATH so I don't have to type in the directory each time, but again, that's part of the OS, nothing to do with MySQL.

    Hmmm...I *did* notice one difference:
    Code:
    C:\Users\Bill>mysql -uroot -p&&&&&
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.5.8 MySQL Community Server (GPL)
    Yours says 5.5.8-log

    No idea why/if that would make a difference. I can't see why it should.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Apr 2011
    Posts
    65
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    That is just too bizarre for words.

    Heck, we are even using the same directory (well, almost...mine says "Bill" instead of "Owner", but the point is that we clearly aren't using any special setup).

    The only thing I see different is that my "root" user was installed to require a password, but I can't see why that would matter, since in either case this *IS* "root" doing the grant.

    Oh...and I added the path to the mysql executable to my windows PATH so I don't have to type in the directory each time, but again, that's part of the OS, nothing to do with MySQL.

    Hmmm...I *did* notice one difference:
    Code:
    C:\Users\Bill>mysql -uroot -p&&&&&
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.5.8 MySQL Community Server (GPL)
    Yours says 5.5.8-log

    No idea why/if that would make a difference. I can't see why it should.
    I don't get it either. Thanks for the help anyway. I seem to be able to create a user with a given password in myphpadmin and then "log on" to that user perfectly fine at the command line. That would lead me to believe there is some error i'm making when creating the user from the command line and not at the "logging in" stage.

    Either way, if i can create password-protected users from phpmyadmin; that will do me for the time being.

    Thanks again

  • #13
    New Coder
    Join Date
    Aug 2011
    Location
    Brisbane, AUS
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great, this was drawing me nuts too.. I was just looking for this. Thanks to Old Pedant, sunfighter and others who contributed.

    Praney

  • #14
    New Coder
    Join Date
    Aug 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    LMAO!

    Code:
     grant all on test.* to 'foo'@'*' identified by 'bar';
    WORKED!

    Using * instead of %

    GO figure.
    I find that pretty interesting. Sometimes little quirks in coding work when you just can't seen any reason for them.


  •  

    Posting Permissions

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