码迷,mamicode.com
首页 > 系统相关 > 详细

linux下忘记密码怎么办,如何重置密码

时间:2014-07-03 20:14:44      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:http   使用   文件   os   art   html   

文章转自:http://www.2cto.com/os/201104/86881.html

以下是网上的方法,我用的是第一种方法,经测试有效。

方法一:
# /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]节提供的密码>
方法四:
方法如下: 1, 关闭mysql服务 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables选项启动mysql服务,可以修 改/etc/inin.d/mysqld脚本启动位置增加此选项, vi /etc/init.d/mysqld
方法如下:
1, 关闭mysql服务
/etc/init.d/mysqld stop
2,使用 –skip-grant-tables选项启动mysql服务,可以修 改/etc/inin.d/mysqld脚本启动位置增加此选项,
vi /etc/init.d/mysqld
在下面运行启动的语句里增加--skip-grant-tables
/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"
--log-error="$errlogfile" --pid-file="$mypidfile"
加入--skip-grant-tables的意思是启动mysql服务的时候跳 过权限表认证。启动后,连接到mysql的root不需要口令
3,重新启动mysql服务
/etc/init.d/mysqld start
4. 修改root用户的密码;
mysql> update mysql.user set password=password(123456) where user=root;
mysql> flush privileges;
mysql> quit
5. 重新启动mysql,就可以使用 新密码登录了。
mysql
mysql -u root –p
输入密码:123456
6,关闭mysql服务
/etc/init.d/mysqld stop
7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原来不变,也就是取消--skip-grant-tables语句
8,重新 启动mysql服务
/etc/init.d/mysqld start

linux下忘记密码怎么办,如何重置密码,布布扣,bubuko.com

linux下忘记密码怎么办,如何重置密码

标签:http   使用   文件   os   art   html   

原文地址:http://www.cnblogs.com/wangkongming/p/3821211.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!