背景:mysql5.6 root已授权所有数据库,执行过下面的语句

grant all privileges on *.* to 'root'@'%' identified by 'root'

当使用root登录,然后新建数据库,新建用户的时候,给新用户授权的时候却提示 access deny

解决办法:

第一步:停服务
命令行:
/etc/init.d/mysql stop
如果不行,就执行下一行:
service mysqld stop
报:
Stopping mysqld: [ OK ]

第二步:跳过密码验证
执行命令行:
# /usr/bin/mysqld_safe --skip-grant-tables
报:
151104 09:07:56 mysqld_safe Logging to '/var/lib/mysql/iZ23dq2wm0jZ.err'.
151104 09:07:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

第三步:无密码登录
执行命令行:
mysql -u root

第四步:授权
mysql>
grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;
关键词解释:
root'@'localhost:是用户
root:是密码

with grant option 这句话就是给root赋予了 给其他用户授权的权限,很关键,跟之前的语句,就差了这几个字符

问题一:发现无密码条件下,没有授权的写权限
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决方法:
mysql> set global read_only=0;//(关掉新主库的只读属性)
mysql>flush privileges;
grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;#再次重新授权
mysql>set global read_only=1;//(读写属性)
mysql>flush privileges;
mysql>exit;
(注意刷新是必须项)

第五步:重启数据库
service mysqld stop
报:
Stopping mysqld: [ OK ]

service mysqld start
报:
Starting mysqld: [ OK ]
或者
service mysqld restart

原文链接:http://blog.csdn.net/nicajonh/article/details/52311402

完美解决Mysql的Access denied for user 'root'@'%的'问题的更多相关文章

  1. mysql登录:access denied for user 'root'@'localhost'(using password:YES)

    mysql登录: access denied for user 'root'@'localhost'(using password:YES) 解决: use mysql; select user,ho ...

  2. mysql中Access denied for user 'root'@'localhost' (using password:YES)

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入“mysql -uroot -pmyadmin”后出现以下错误: “Access ...

  3. mysql中Access denied for user 'root'@'localhost' (using password:YES)(zhuan)

    错误代码 1045Access denied for user 'root'@'localhost' (using password:YES) 如果你的mysql也出现以上这种提示, 建议你逐个字看完 ...

  4. MySQL 出现 Access denied for user 'root'@'localhost' (using password: YES) 错误

    登录某台服务器的mysql时候总报错: mysql2/client.rb:58:in `connect': Access denied for user 'root'@'localhost' (usi ...

  5. linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

    linux连接mysql /usr/local/mysql/bin/mysql -uroot -p 输入密码出现Access denied for user 'root'@'localhost'(us ...

  6. MySQL出现Access denied for user ‘root’@’localhost’ (using password:YES)

    连接时MySQL出现了下面的错误: Access denied for user ‘root’@’localhost’ (using password:YES) 解决的办法是先停止MySQL服务,在m ...

  7. 登录mysql 报 Access denied for user 'root'@'localhost' 错误

    安装mysql后登录提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 解决如下 ...

  8. mysql错误 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES)

    mysql -u root -p Aaa111222333 grant all privileges on *.* to root@'%' identified by 'aaa111222333; Q ...

  9. MySQL出现Access denied for user 'root'@'%' to database 'netai_test'问题

    访问数据库时报错信息 Access denied for user 'root'@'%' to database 'netai_test' 原因:这是由于创建数据库后没有对用户授权,使用户可以访问数据 ...

随机推荐

  1. jenkins介绍及其简单操作

    一.jenkins简介 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. Jenkins功能包 ...

  2. Python中sort和sorted函数代码解析

    Python中sort和sorted函数代码解析 本文研究的主要是Python中sort和sorted函数的相关内容,具体如下. 一.sort函数 sort函数是序列的内部函数 函数原型: L.sor ...

  3. Pythoncookbook(数据结构与算法)在字典中将键映射到多个值上的方法

    Python cookbook(数据结构与算法)在字典中将键映射到多个值上的方法 本文实例讲述了Python在字典中将键映射到多个值上的方法.分享给大家供大家参考,具体如下: 问题:一个能将键(key ...

  4. MySQL使用order by field()自定义排序

    MySQL的自定义排序和Oracle相比,要简单得多. 假设在表v_education的列schoolRecord中,有以下字段:'小学','初中','高中','专科','本科','硕士','博士'. ...

  5. vue中封装swipe组件

    <template> <!-- TODO swipe --> <div id="hy-swiper"> <div class=" ...

  6. 【AMAD】schema -- 使用pythonic的方式进行schema验证

    动机 简介 用法 个人评分 动机 验证数据是否符合规范是很有用的,比如: 用于单元测试 用于验证用户提交的数据是否合法 简介 schema1是一个用来验证python数据结构的库. 可以用来验证诸如: ...

  7. 华为HCNA乱学Round 4:RIP

  8. 【C/C++语言】指针常量与常量指针的区别

    三个名词虽然非常绕嘴,不过说的非常准确.用中国话的语义分析就可以很方便地把三个概念区分开. 一) 常量指针. 常量是形容词,指针是名词,以指针为中心的一个偏正结构短语.这样看,常量指针本质是指针,常量 ...

  9. icon.css

    .icon-blank{ background:url('icons/blank.gif') no-repeat; } .icon-add{ background:url('icons/edit_ad ...

  10. netcore发布的坑

    当我选择目标运行时为Linux-64时,生成的接口为第二图, 而当我选择目标运行时为可移植或windows-64时,生成的接口则是正确的.和我写的代码,以及本地按F5启动调试的效果一致. 整个项目从v ...