MySQL無法使用我創建的用戶

[英]MySQL can't use a user that I create


In MySQL I create two users:

在MySQL中我創建了兩個用戶:

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

然后,當我嘗試連接時:“mysql -u Alice -p”它失敗了,告訴我

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.

MySQL要求輸入密碼,而我putand給我的錯誤。

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

編輯2:我在遠程連接,而不是在本地連接,所以唯一必須工作的是Alice。

3 个解决方案

#1


0  

Log in as root and do this:

以root身份登錄並執行以下操作:

GRANT ALL privileges ON *.* TO Bob@localhost IDENTIFIED BY 'p' WITH GRANT OPTION;

#2


0  

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

根據創建MySQL用戶時使用%for host的注釋,

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

實際上,'localhost'在mysql中是特殊的,它意味着通過unix套接字(或我認為的Windows上的命名管道)的連接,而不是TCP / IP套接字。使用%作為主機不包括'localhost' - nos 5月30日'12在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

因此,如果您的mysql -u alice ...命令使用Unix套接字而不是127.0.0.1連接,則需要

CREATE USER 'Alice'@'localhost' IDENTIFIED by 'a'

#3


0  

did you tried flushing privileges with that command ?

你試過用那個命令刷新特權嗎?

FLUSH PRIVILEGES;

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/05/27/89b18bb75e4c814503e106645539c5b2.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com