mysql数据库登录时出现报错
解决方法:
[root@localhost local]# vim /etc/my.cnf ##修改etc下面的配置文件my.cnf
在底行加入
skip-grant-tables ##免密登录;wq保存
重启服务
[root@localhost local]# systemctl restart mysqld
这时用mysql -uroot -p去登录是不需要密码的
更改以root身份登录的密码,这边密码设置为123456
mysql> update mysql.user set authentication_string=password('123456') where user='root';
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges; ##刷新数据库
Query OK, 0 rows affected (0.00 sec)
退出数据库;再次修改/etc/my.cnf文件,将添加的免密登录去掉
重启服务后,再次登录数据库