0

In MySQL I create two users:

CREATE USER 'Bob'@'localhost' IDENTIFIED by 'p'
CREATE USER 'Alice'@'%' IDENTIFIED by 'a'

And then, when I try to connect with: "mysql -u Alice -p" it fails, telling me

Error 1045 (28000) Access denied for user 'Alice'@'localhost'

T The same with Bob.

Anyone knows why occur this?

EDIT:

MySQL asks for the password, and the I putand give me that error.

EDIT 2: I am connecting in remote, not in local, so the only that must work is Alice.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Elseine
  • 741
  • 2
  • 11
  • 23
  • what about `mysql -u 'Alice'@'%' -pa` ? I've been facing similar problems recently and apparently depending on your version of mysql, you'll have to specify the @... part – Sebas May 27 '13 at 20:09
  • Nop, "Access denied for user 'Alice@%'@'localhost' – Elseine May 27 '13 at 20:13

3 Answers3

0

Log in as root and do this:

GRANT ALL privileges ON *.* TO Bob@localhost IDENTIFIED BY 'p' WITH GRANT OPTION;
ramonovski
  • 404
  • 3
  • 16
0

did you tried flushing privileges with that command ?

FLUSH PRIVILEGES;
Sebas
  • 21,192
  • 9
  • 55
  • 109
tanaydin
  • 5,171
  • 28
  • 45
0

According to a comment in Using % for host when creating a MySQL user,

Actually there is, 'localhost' is special in mysql, it means a connection over a unix socket (or named pipes on windows I believe) as opposed to a TCP/IP socket. using % as the host does not include 'localhost' – nos May 30 '12 at 20:45

As a result, if your mysql -u alice... command connects using a Unix socket rather than at 127.0.0.1, you'll need to

CREATE USER 'Alice'@'localhost' IDENTIFIED by 'a'
Community
  • 1
  • 1
incaren
  • 191
  • 1
  • 6