mysql 创建帐号出现 Access denied for user 'root'@'localhost'错误(转载)
从供应商那边接手一个MySQL数据库(数据库版本为5.7.21 MySQL Community Server (GPL)),在创建账号时遇到了“ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database xxx”错误,如下所示
mysql> grant all on xxx.* to xxx@'192.168.%' identified by 'xxx';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'xxxx'
mysql>
照理说,root用户应该有任何权限,那么为什么出现这个错误呢? 查看当前用户为root@localhost,顺便查看了一下各个root账号的权限。如下所示:
mysql> select current_user() from dual;
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec
mysql> select host,user from user where user='root';
+-----------+----------+
| host | user |
+-----------+----------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+----------+
7 rows in set (0.00 sec)
mysql> show grants for root@'localhost';
+--------------------------------------------------------------+
| Grants for root@localhost |
+--------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+--------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> show grants for root@'127.0.0.1';
+---------------------------------------------------------------------+
| Grants for root@127.0.0.1 |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show grants for root@'%';
+-------------------------------------------+
| Grants for root@% |
+-------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' |
+-------------------------------------------+
1 row in set (0.00 sec)
如上所示,root@localhost账号没有WITH GRANT OPTION选项,关于WITH GRANT OPTION选项,如果想让授权的用户,也可以将这些权限授予给其他用户,需要选项 “WITH GRANT OPTION“ 。也就是说有这个选项就可以将权限传递给第三方。这也是上面root@localhost用户给其它用后授权报错的原因,如果以 root@127.0.0.1登录(此账号拥有WITHGRANT OPTION选项),创建用户并授权就不会有这个错误,如下所示:
# mysql -host 127.0.0.1 -u root -p
Enter password:
mysql> grant all on xxx.* to xxx@'192.168.%' identified by 'test1249';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
当然还有其它方面的原因也可能会引起这个错误,不过在这个案例当中,确实仅仅是因为上面原因引起。特此记录一下这个案例@!
mysql 创建帐号出现 Access denied for user 'root'@'localhost'错误(转载)的更多相关文章
- mysql Access denied for user root@localhost错误解决方法总结(转)
mysql Access denied for user root@localhost错误解决方法总结(转) mysql Access denied for user \'root\'@\'local ...
- (转载)解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
今天想用用MySQL 数据库 谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到 ...
- 转: windows系统下mysql出现Error 1045(28000) Access Denied for user 'root'@'localhost'
windows系统下mysql出现Error 1045(28000) Access Denied for user 'root'@'localhost' 转自 http://zxy5241.space ...
- Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Linux: MyS ...
- yum 安装 Mysql error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 开启远程连接 修改登入密码 忘记root密码 配置防火墙规则 随手mark
yum 安装 MYsql: yum install mysql mysql-server mysql-devel -y 1.1 登入报错: ERROR 1045 (28000): Acc ...
- 解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
今天想用用MySQL 数据库 谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到 ...
- mysql Access denied for user root@localhost错误解决方法总结
原文:http://www.111cn.net/database/mysql/44142.htm Access denied for user 'root'@'localhost' (using pa ...
- Ubuntu下 MySQL的“ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)”
今天闲来无事,在Ubuntu上掏鼓一下mysql.但尴尬的是,当我输入mysql -u root -p的时候,抛出了一个错误:ERROR 1045 (28000): Access denied for ...
- 登录mysql 报 Access denied for user 'root'@'localhost' 错误
安装mysql后登录提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 解决如下 ...
随机推荐
- 在Ubuntu下搭建Android开发环境(AndroidStudio)
在ubuntu下搭建Android开发环境 本教程的开发环境的搭建有三个大步骤:安装Java jdk,安装Android studio,安装sdk 笔者搭建环境的时候用的是Ubuntu18.04 1. ...
- Codeforces 460C 二分结果+线段树维护
发现最近碰到好多次二分结果的题目,上次多校也是,被我很机智的快速过了,这个思想确实非常不错.在正面求比较难处理的时候,二分结果再判断是否有效往往柳暗花明. 这个题目给定n个数字的序列,可以操作m次,每 ...
- Storm 流式计算框架
1. 简介 是一个分布式, 高容错的 实时计算框架 Storm进程常驻内存, 永久运行 Storm数据不经过磁盘, 在内存中流转, 通过网络直接发送给下游 流式处理(streaming) 与 批处理( ...
- 吴裕雄--天生自然C++语言学习笔记:C++ 多态
多态按字面的意思就是多种形态.当类之间存在层次结构,并且类之间是通过继承关联时,就会用到多态. C++ 多态意味着调用成员函数时,会根据调用函数的对象的类型来执行不同的函数. 下面的实例中,基类 Sh ...
- ACM-Checker Challenge
题目描述:Checker Challenge 1000(ms) 10000(kb) 20 / 90 Examine the 6x6 checkerboard below and note tha ...
- junit基础学习之-引用spring容器的测试(7)
context 自动注入的文章链接:http://www.360doc.com/content/11/0815/09/2371584_140471325.shtml
- md5sum|zip|
##move## ;i<=;i++));do cp combine_all.split_$i split_$i;done ##gzip## mkdir gzip/workshell ;i< ...
- JS ~ 返回上一步
<a href=" javascript:window.history.back() "> 返回上一步 </a>
- 2. react 简书 头部 (header) 样式编写
1. 在 src 下 创建 common 文件下 创建 header 文件夹下 创建 index.js #src/common/header/index.js import React, {Compo ...
- AndroidAutoLayout
AndroidAutoLayout [DEPRECATED]Android屏幕适配方案,直接填写设计图上的像素尺寸即可完成适配. 目前没有精力,已停止维护,使用前务必看明白代码,明确该方案可以解决自身 ...