Mysql登錄報1045錯誤
MySQL在使用root密碼登陸報 1045
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
錯誤可能原因:
1、有空用戶的現(xiàn)象,MySQL官方的BUG,優(yōu)先匹配到空用戶
2、權(quán)限錯誤
一、空用戶問題解決方法
先修改下mysql的配置文件,設(shè)置免密鑰登陸:

skip-grant-tables
然后重新啟動mysql,
/etc/init.d/mysqld restart
在mysql命令行中執(zhí)行下面命令:

USE mysql;
Delete FROM user Where User='' and Host='localhost';
FLUSH PRIVILEGES;
執(zhí)行完后將剛才添加的
skip-grant-tables 注釋 然后重新啟動mysql
現(xiàn)在再用賬號密碼登陸就可以登陸進去了。
二、MySQL root權(quán)限導(dǎo)致的無法登錄
1、同樣是修改成免密碼登錄的方式:

2、重啟數(shù)據(jù)庫:
/etc/init.d/mysqld restart

3、更改root權(quán)限:
update mysql.user set password=password('root 用戶密碼') where user='root' and host='localhost';
FLUSH PRIVILEGES;
4、注銷跳過密碼登錄的配置
然后重啟mysql數(shù)據(jù)庫,使用root登錄就正常了
篤信仁厚,慎思勤勉

浙公網(wǎng)安備 33010602011771號