这一般是密码错误问题,你需要确认你的密码是否正确,实在想不起来可以改密码。
一、 查看默认密码
如果你是刚刚安装的mysql,使用以下命令查看默认密码
grep 'temporary password' /var/log/mysqld.log
这个默认密码会是一串奇奇怪怪的东西,要记住localhost:后面的一串全都是他的默认密码,包括标点符号,比如我的
密码则是QXjoQ.JS1T/,
,包括“/”和“,”。
二、修改密码
(1)跳过MySQL的密码认证过程
#vim /etc/my.cnf
(2)重启mysql
service mysqld restart
(3)修改root的密码
mysql -u root -p //输入完回车,若需要输入密码,也直接回车
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit
若出现ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 错误。则执行下 flush privileges
命令,再执行该命令即可。