首页 / MYSQL / mysql 数据库增加用户与为用户授权。 ERROR 1133 (42000): Can't find any matching row in the user table。
mysql 数据库增加用户与为用户授权。 ERROR 1133 (42000): Can't find any matching row in the user table。
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql 数据库增加用户与为用户授权。 ERROR 1133 (42000): Can't find any matching row in the user table。,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2583字,纯文字阅读大概需要4分钟。
内容图文
ERROR 1133 (42000): Can't find any matching row in the user table
文章目录
1、问题描述
使用
set password for 'root'@'localhost'=password('MyNewPass4!');
命令修改mysql
数据库root
用户密码提示**ERROR 1133 (42000): Can't find any matching row in the user table
**错误
2、主要原因
-
错误提示的字面意思:
在用户表中找不到任何匹配的行
-
登录
mysql
执行以下命令
use mysql;
select Host,User from user;
- 1
主要原因是修改密码的条件不否
3、解决办法
- 将
set password for 'root'@'localhost'=password('MyNewPass4!');
代码中的localhost
修改%
,与数据库Host
字段值一致
set password for 'root'@'%'=password('MyNewPass4!');
- 刷新
flush privileges;
===================================================================================================================
自我测试案例如下 :
因为在客户端进行连接的时候没有权限,报错如下:
在进行授权的时候发现 报错 1133,如下所示。
[root@localhost][mysql]> grant all privileges on *.* to 'root'@'%' with grant option; ERROR 1133 (42000): Can't find any matching row in the user table
这是因为,在授权进行授权的时候 ,需要读取 mysql.user 表中的记录。如果没有 ‘root’@'%' 这条记录,那么就不能授权,如下所示
[root@localhost][mysql]> select Host,User from user; +----------------+---------------+ | Host | User | +----------------+---------------+ | 192.168.17.182 | repl | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +----------------+---------------+ 4 rows in set (0.00 sec)
那么需要进行 增加用户的操作:
[root@localhost][mysql]> create user 'root'@'%' identified by '123456'; Query OK, 0 rows affected (0.00 sec)
然后我们再来查询 mysql.user 的记录,可以发现有了 ‘root’@'%' 这条记录 :
[root@localhost][mysql]> select host,user from user; +----------------+---------------+ | host | user | +----------------+---------------+ | % | root | | 192.168.17.182 | repl | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +----------------+---------------+ 5 rows in set (0.00 sec)
下面再进行授权就没有问题了:
[root@localhost][mysql]> flush privileges; Query OK, 0 rows affected (0.01 sec) [root@localhost][mysql]> grant all privileges on *.* to 'root'@'%'; Query OK, 0 rows affected (0.01 sec)
也可以如下进行授权:
[root@localhost][mysql]> grant all privileges on *.* to 'root'@'%' with grant option; Query OK, 0 rows affected (0.00 sec) [root@localhost][mysql]> [root@localhost][mysql]> flush privileges; Query OK, 0 rows affected (0.01 sec)
然后在客户端可以访问了。
内容总结
以上是互联网集市为您收集整理的mysql 数据库增加用户与为用户授权。 ERROR 1133 (42000): Can't find any matching row in the user table。全部内容,希望文章能够帮你解决mysql 数据库增加用户与为用户授权。 ERROR 1133 (42000): Can't find any matching row in the user table。所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。