mysql -uroot -p

输入设置的密码

竟然报错了!

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE)


密码留空

还是错误!

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


于是重改密码!

# /etc/init.d/mysql stop

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

mysql <-----登录

mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; <----修改密码

mysql> FLUSH PRIVILEGES;





假如忘记了登录mysql的root用户的密码

#/etc/init.d/mysqld stop

手动启动数据库

#mysqld_safe --skip-grant-tables --skip-networking &

#mysql //登录

(这种情况下,就不能使用grant来修改密码,只能用update来修改密码)

>update mysql.user set password=password('123456') where user='root'; //重新修改密码

#/etc/init.d/mysqld restart //重启数据库

skip-grant-tables //跳过赋权表

skip-networking //跳过网络