mysql新用户访问被拒绝

标签 mysql

刚开始接触mysql。我使用 root 登录并按照在线引用创建新用户:

mysql> CREATE USER 'abc'@'%' IDENTIFIED BY '111111';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'abc'@'%' WITH GRANT OPTION;

然后我退出并尝试使用新用户登录:

mysql --user=abc --password=111111 mysql

但是得到一个错误信息:

Access denied for user 'abc'@'localhost' (using password: YES)

我错过了什么吗?

最佳答案

运行这个来工作

FLUSH PRIVILEGES

一旦您为您的用户授予了所需的权限,您将需要 FLUSH 权限以完成设置并使新设置生效。为此,请在 SQL 命令提示符下运行此命令:

[编辑]
如果您还想从本地主机连接,您应该创建另一个帐户。

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. )

仅供引用:http://dev.mysql.com/doc/refman/5.5/en/adding-users.html

关于mysql新用户访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14098242/

相关文章:

mysql - 如何在服务器版本 5.5 上运行 IF 条件

php - yii语言本地化mysql表数据进入 View

PHP & MySQL : make chemical reaction

mysql - 简单的 SELECT COUNT SQL 查询错误

php - 将 jquery datepicker 创建的日期转换为标准的 mysql dateformat

php - 如何从多个 mysql 列中选择不同的值并将它们放入一个 PHP 数组中?

PHP 表单处理 - 使用多个用户输入连接表

mysql - Symfony,OneToMany 属性的 Doctrine 顺序

php - 注册后如何自动登录

php - mysql版本更新中Moodle配置错误