mysql 新用户访问被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14098242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql new user access denied
提问by Ryan
Just started with mysql. I login with root and follow the online reference to create a new user:
刚开始用mysql。我使用 root 登录并按照在线参考创建一个新用户:
mysql> CREATE USER 'abc'@'%' IDENTIFIED BY '111111';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'abc'@'%' WITH GRANT OPTION;
then I quit and tried to login with the new user:
然后我退出并尝试使用新用户登录:
mysql --user=abc --password=111111 mysql
But got an error message:
但是收到一条错误信息:
Access denied for user 'abc'@'localhost' (using password: YES)
用户 'abc'@'localhost' 访问被拒绝(使用密码:YES)
Did I missed something?
我错过了什么吗?
回答by Venu
Run this to work
运行这个工作
FLUSH PRIVILEGES
Once you have given the desired privileges for your user, you will need to FLUSH privileges in order to complete the setup and to make the new settings work. To do so, run this command within the SQL command prompt:
一旦您为您的用户提供了所需的权限,您将需要 FLUSH 权限才能完成设置并使新设置生效。为此,请在 SQL 命令提示符下运行此命令:
[EDIT]
If you want to connect from localhost also, you should create another account.
[编辑]
如果您还想从 localhost 连接,您应该创建另一个帐户。
It is necessary to have both accounts for 'user' to be able to connect from anywhere as 'user'. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when 'user' connects from the local host. As a result, 'user'would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'user'@'%' account and thus comes earlier in the user table sort order. )
必须同时拥有“用户”的两个帐户才能以“用户”的身份从任何地方进行连接。如果没有 localhost 帐户,当“用户”从本地主机连接时,由 mysql_install_db 创建的 localhost 的匿名用户帐户将优先。因此,“用户”将被视为匿名用户。其原因是匿名用户帐户具有比 'user'@'%' 帐户更具体的 Host 列值,因此在用户表排序顺序中排在更早的位置。)
FYI: http://dev.mysql.com/doc/refman/5.5/en/adding-users.html
仅供参考:http: //dev.mysql.com/doc/refman/5.5/en/adding-users.html
回答by BaiJiFeiLong
Change host from '%' to 'localhost' worked for me.
将主机从 '%' 更改为 'localhost' 对我有用。
However I do not know why.
然而我不知道为什么。
Remeber to 'flush privileges;'
记住“刷新特权”;
I am using mysql Ver 15.1 Distrib 10.1.32-MariaDB, for Linux (x86_64) using readline 5.1
我正在使用mysql Ver 15.1 Distrib 10.1.32-MariaDB,用于 Linux (x86_64) 使用 readline 5.1
回答by Daniel Adenew
This is it.
就是这个。
grant all privileges on *.* to `root`@`%` identified by 'chnagethepasswordhere';
flush privileges;
--helps to excute store procedure as root user
GRANT EXECUTE ON PROCEDURE mbu4u.ratingProcedure TO 'root'@'ip.ip.ip.ip' identified by 'changepasswordheere';
GRANT ALL ON mbu4u.* TO root@'ip.ip.ip.ip' IDENTIFIED BY 'changepassword';