root用户无法访问Mysql数据库问题的解决

在使用Centos系统远程访问Mysql数据库的时候,系统提示报如下错误:

Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

经过验证以下方案可以解决问题:

1.首先停止mysql服务器

sudo service mysqld stop

2.无权限启动mysql服务

sudo service mysqld start --skip-grant-tables

3..登录mysql

mysql

4..重新载入权限

FLUSH PRIVILEGES;

5.. 选择系统数据库mysql

use mysql;

6..查询系统表user中的用户

select host,user,authentication_string from user;

7.向root用户赋值权限

GRANT USAGE ON *.* TO 'root'@'localhost' IDENTIFIED BY 'YourPassword' WITH GRANT OPTION;

 

原文地址:https://www.cnblogs.com/crazyguo/p/9969680.html