linuxmysql忘记密码的多种解决或Accessdeniedforuser'root'@'localhost'
2023-06-13 09:14:11 时间
我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
#mysql-uroot-p
Enterpassword:
ERROR1045(28000):Accessdeniedforuser"root"@"localhost"(usingpassword:NO)
使用网上介绍的方法修改root用户的密码:
#mysqladmin-uroot-ppassword"newpassword"
Enterpassword:
mysqladmin:connecttoserverat"localhost"failed
error:"Accessdeniedforuser"root"@"localhost"(usingpassword:YES)"
现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
#/etc/init.d/mysqlstop
#mysqld_safe--user=mysql--skip-grant-tables--skip-networking&
#mysql-urootmysql
mysql>UPDATEuserSETPassword=PASSWORD("newpassword")whereUSER="root";
mysql>FLUSHPRIVILEGES;
mysql>quit
#/etc/init.d/mysqlrestart
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
#mysql-udebian-sys-maint-p
Enterpassword:<输入[client]节的密码>
mysql>UPDATEuserSETPassword=PASSWORD("newpassword")whereUSER="root";
mysql>FLUSHPRIVILEGES;
mysql>quit
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
#mysql-uroot-p
Enterpassword:<输入/etc/mysql/debian.cnf文件中[client]节提供的密码>
至此,困惑多时的问题解决了!
#mysql-uroot-p
Enterpassword:
ERROR1045(28000):Accessdeniedforuser"root"@"localhost"(usingpassword:NO)
使用网上介绍的方法修改root用户的密码:
#mysqladmin-uroot-ppassword"newpassword"
Enterpassword:
mysqladmin:connecttoserverat"localhost"failed
error:"Accessdeniedforuser"root"@"localhost"(usingpassword:YES)"
现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
#/etc/init.d/mysqlstop
#mysqld_safe--user=mysql--skip-grant-tables--skip-networking&
#mysql-urootmysql
mysql>UPDATEuserSETPassword=PASSWORD("newpassword")whereUSER="root";
mysql>FLUSHPRIVILEGES;
mysql>quit
#/etc/init.d/mysqlrestart
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
#mysql-udebian-sys-maint-p
Enterpassword:<输入[client]节的密码>
mysql>UPDATEuserSETPassword=PASSWORD("newpassword")whereUSER="root";
mysql>FLUSHPRIVILEGES;
mysql>quit
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
#mysql-uroot-p
Enterpassword:<输入/etc/mysql/debian.cnf文件中[client]节提供的密码>
至此,困惑多时的问题解决了!
相关文章
- 生成IOS app专用密码教程
- Oracle密码错误次数过多账号锁定的问题(推荐)
- 可以指定要生成的密码长度的Python代码详解编程语言
- 保护机密安全:Linux 用户密码设置注意事项(linux用户密码设置)
- Linux脚本实现安全输入密码(linux脚本输入密码)
- 如何在Linux中管理帐户密码
- 解密MySQL中的MD5加密密码(mysqlmd5解密)
- 修改MySQL密码的6步指南(mysql密码怎么改)
- MySQL数据库密码丢失,怎么办?(mysql数据库密码忘了)
- MySQL简单实现不需登录修改密码方法(mysql不登录修改密码)
- Redis设置密码出错排查解决方法(redis设置密码报错)
- Redis使用登录名密码进行安全保护(redis设置登录名密码)
- Windows中MySQLroot用户忘记密码解决方案