游戏技术文章

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)MySql忘记root账户的密码

时间:2016-8-19 18:20:55  作者:棋牌资源网  来源:棋牌资源网  查看:7873  评论:0
内容摘要:我的系统是Ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:# mysql -uroot -pEnter password:ERROR 1045 (28000): Access denied for user 'root'@...
我的系统是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>

ysql>
 
 
 
方法二:
直接使用/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]节提供的密码>
 
至此,困惑多时的问题解决了!


方法四:
操作系统:WINDOWS-XP 系统
 
数据库版本:mysql 5.x
 
 
提示:access denied for user 'root'@'localhost' using password yes/no
 
原来都好好的,今天开机上来提示上面的这个错误,重启 MySQL 还是不可以。
 
 
注意我这里的环境是 WINDOWS-XP 系统,LINUX 系统下的操作没有验证过,情况不清楚。
 
 
1. 管理员登陆系统,停止 MySQL 服务或者结束 MySQL 进程。
 
 
2. 启动 WINDOWS 的命令行窗口(即通常的 DOS 窗口:运行cmd),切换到你的 “MySQL\bin” 目录下。
例如我的是 “D:\Program Files\MySQL\MySQL Server 5.2\bin”,然后执行下面的粗体的命令:(注意你的 “my.ini” 位置)
 
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
 
C:\Documents and Settings\Administrator>cd D:\Program Files\MySQL\MySQL Server 5.2\bin
 
C:\Documents and Settings\Administrator>d:
 
D:\Program Files\MySQL\MySQL Server 5.2\bin>mysqld --defaults-file="D:\Program Files\MySQL\MySQL Server 5.2\my.ini" --console --skip-grant-tables 
 
100608 9:04:12 InnoDB: Started; log sequence number 0 46409
100608 9:04:12 [Note] mysqld: ready for connections.
Version: '5.2.0-falcon-alpha-community' socket: '' port: 3306 MySQL Community
Server (GPL)
100608 9:06:57 [Warning] Found invalid password for user: 'root@localhost'; Ign
oring user

 
只要出现上面信息,就说明 MySQL 已经起来了。
 
 
3. 不关闭此命令行窗口,重新打开一个命令行窗口,同样切到 “MySQL\bin” 目录下,然后执行下面的粗体的命令:
 
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
 
C:\Documents and Settings\Administrator>cd D:\Program Files\MySQL\MySQL Server 5.2\bin
 
C:\Documents and Settings\Administrator>d:
 
D:\Program Files\MySQL\MySQL Server 5.2\bin>mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.2.0-falcon-alpha-community MySQL Community Server (GPL)
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
然后,就是重新设置密码了!

mysql> UPDATE user SET Password=PASSWORD('root') where USER='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit
Bye
 
4. 好了到此步,可以关闭第一个 DOS 窗口了(关闭服务)。打开系统服务控制窗口(控制面板--管理工具--服务),启动 MySQL 服务。
 
5. 在剩下的第二个 DOS 窗口中,用新的 ROOT 密码连接 MySQL。
 
D:\Program Files\MySQL\MySQL Server 5.2\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.2.0-falcon-alpha-community-nt MySQL Community Server (GPL)
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> quit
Bye
 
 
 
至此,系统恢复 ROOT 用户管理权限完成,就是管理员密码的问题,奇怪,官方安装的时候不给出解决方法,貌似已存在很久了。。

标签:ERROR1045(28000) MySql忘记root账户的密码 

欢迎加入VIP,【VIP售价:只要288元永久VIP会员】畅享商业棋牌游戏程序下载,点击开通!

下载说明


☉本站所有源码和资源均由站长亲自测试-绝对保证都可以架设,运营!
☉如源码和资源有损坏或所有链接均不能下载,请告知管理员,

☉本站软件和源码大部分为站长独资,资源购买和收集,放心下载!

☉唯一站长QQ:1004003180  [人格担保-本站注重诚信!]

☉购买建议E-mail:1004003180@qq.com   源码收购 E-mail:1004003180@qq.com    

☉本站文件解压密码  【文章内都自带解压密码,每个密码不同!】


本站提供的所有源码,均来源站长提供,仅学习交流 浙ICP备09009969号

由此产生不良后果和法律责任与本站无关,如果侵犯了您的版权,请来信告知 1004003180@qq.com 将及时更正和删除! 

Copyright © 2008-2024 棋牌资源网,你身边的棋牌资源下载站    All Rights Reserved