好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

ERROR 1045 (28000): Access denied for user root@lo

出现的情况: 安装完mysql之后,执行 mysql -uroot -p,然后输入设置的密码,就如下错误: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决办法:

方法一: 一般执行 # ./mysqladmin -uroot password '你的新密码' 即可修改回来。

方法二: # /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; mysql> FLUSH PRIVILEGES; mysql> quit # /etc/init.d/mysql restart # mysql -uroot -p Enter password: <输入新设的密码newpassword> mysql> 方法三: 直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码: # mysql -udebian-sys-maint -p Enter password: <输入[client]节的密码> mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; mysql> FLUSH PRIVILEGES; mysql> quit # mysql -uroot -p Enter password: <输入新设的密码newpassword> mysql> 测试一下: # mysql -uroot -p Enter password:

mysql>

至此,困惑多时的问题解决了!

查看更多关于ERROR 1045 (28000): Access denied for user root@lo的详细内容...

  阅读:42次