...

View Full Version : Error 1045 (28000)



gnolan
05-26-2011, 10:35 AM
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.




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>

gnolan
05-27-2011, 09:17 AM
bump.

Anyone got any ideas

sunfighter
05-27-2011, 05:39 PM
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/en/adding-users.html

Old Pedant
05-27-2011, 08:32 PM
Correct, Sunfighter. Unless you *want* to be restrictive, I recommend using 'username'@'%'

gnolan
05-27-2011, 10:13 PM
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.

Old Pedant
05-27-2011, 10:31 PM
Well, I don't pretend to understand why, but I had the same problem.

But when I then changed to use


grant all on test.* to 'foo'@'localhost' identified by 'bar';

it worked fine. I'd swear I had used @'%' before, but... Whatever works.

Old Pedant
05-27-2011, 10:34 PM
LMAO!



grant all on test.* to 'foo'@'*' identified by 'bar';


WORKED!

Using * instead of %

GO figure.

gnolan
05-30-2011, 09:43 AM
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:



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.

Old Pedant
05-30-2011, 07:33 PM
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:



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.

gnolan
06-01-2011, 11:43 AM
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



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>

Old Pedant
06-01-2011, 11:11 PM
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:


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.

gnolan
06-01-2011, 11:36 PM
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:


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

praneybehl
08-13-2011, 11:44 AM
Great, this was drawing me nuts too.. I was just looking for this. Thanks to Old Pedant, sunfighter and others who contributed. :)

Praney

beautifulday
08-27-2011, 03:06 PM
LMAO!



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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum