Chinaunix首页 | 论坛 | 博客
  • 博客访问: 687540
  • 博文数量: 34
  • 博客积分: 4020
  • 博客等级: 上校
  • 技术积分: 367
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-05 16:22
文章分类

全部博文(34)

文章存档

2010年(1)

2009年(16)

2008年(9)

2007年(8)

我的朋友

分类: Mysql/postgreSQL

2007-05-20 00:33:34

我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
# /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>


方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
# mysql -uroot -p
Enter password: <输入/etc/mysql/debian.cnf文件中[client]节提供的密码>

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




阅读(207388) | 评论(37) | 转发(3) |
给主人留下些什么吧!~~

chinaunix网友2009-08-19 14:12:10

高手啊,差点我就重装mysql了。谢谢。

br98520002009-06-02 11:48:48

谢谢啊 !!

chinaunix网友2009-05-20 11:31:52

太感謝了! 在放棄它之前的最後一刻看到了這篇,得救了! 再次感謝!

chinaunix网友2009-03-24 09:56:37

谢谢呀,我终于能用了,第三种方法很好用

chinaunix网友2009-03-10 20:03:56

谢谢楼主