目录
1、背景
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的关系数据库管理系统应用软件。
在日常的使用MySQL的过程中,有时候登录正确的密码后还是报下面这个错误(rpm 安装的MySQL 5.7)
[root@hadoop105 ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
2、解决方法
1.配置无密码
vim /etc/my.cnf
在[mysqld]里配置跳过密码进行登陆
skip-grant-tables
2.重启MySQL数据库
service mysqld restart
mysql -uroot -p #不输入密码直接回车进入MySQL
重新赋密码并且授权账户远程登录权限
use mysql;
select user,host from user;
update mysql.user set authentication_string=password('123456') where User="root" ;
flush privileges; #刷新系统授权表
grant all privileges on *.* to root@'%'; #授权root账户远程访问权限
flush privileges; #刷新系统授权表
3.再次修改my.cnf,注释掉my.cnf,重启MySQL,输入更改后的密码即可
vim /etc/my.cnf
#skip-grant-tables
service mysqld restart
mysql -uroot -p
有用点赞收藏吧!