找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
楼主: 笑傲中国

linux下mysql的root密码忘了

[复制链接]
发表于 2007 年 4 月 29 日 16:37:31 | 显示全部楼层
介绍一个在所有版本linux的grub上均可以使用的方法:

1、在Grub的引导装载程序菜单上,选择你要进入的条目,键入 “e” 来进入编辑模式;

2、在第二行(类似于kernel /vmlinuz-2.6.15 ro root=/dev/hda2 ),键入”e”进入编辑模式;

3、在句末加上”init=/bin/bash”,回车;

4、按“b”启动系统。

这样我们即可获得一个bash的shell,进入shell后,根分区的挂载模式默认是只读,我们要将其改为可写,否则不能更改root密码:

mount -no remount,rw /
passwd root
sync
mount -no remount,ro /
reboot

这样即可成功更改debian的root用户的密码。


走前灌水
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 4 月 29 日 16:37:34 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
我的mysql为MySQL - 5.0.23:

1、在开始菜单“运行”栏里输入“CMD”,进入到了命令行下
C:\Documents and Settings\millken>
C:\Documents and Settings\millken>net stop mysql            
C:\Documents and Settings\millken>mysqld-nt --skip-grant-tables
C:\Documents and Settings\millken>

2、新开一个CMD窗口:
*************************************************************************
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.

C:\Documents and Settings\millken>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 5.0.23-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Database changed
mysql> update user set password=password("root") where host="localhost" and user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> set password for "root"@"localhost"=old_password("root");
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables
option so it cannot execute this statement
mysql> exit;
Bye

C:\Documents and Settings\millken>d:

D:\>mysqladmin -u root shutdown

D:\>net start mysql

MySQL 服务已经启动成功。


D:\>cd www

D:\WWW>cd mysql

D:\WWW\MYSQL>cd bin

D:\WWW\MYSQL\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35 to server version: 5.0.23-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> set password for 'root'@'localhost'=old_password("root");
Query OK, 0 rows affected (0.00 sec)

mysql>



至此就大功告成了,注意一点的是因为5.0.1版Mysql的password算法和3.23.44的算法不一样了,所以要运行最后一句,不然phpmyadmin下会进不了。


LINUX下大致一样,就是命令稍有不同
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 4 月 29 日 16:39:02 | 显示全部楼层
相信11楼的
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 4 月 29 日 16:41:05 | 显示全部楼层
我华丽的飘过..........
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 4 月 29 日 16:41:56 | 显示全部楼层
别信我。。。套套用LINUX用的多,找他
其实最方便的还是找个最新的溢出程序,入侵最方便。。
最多是个“日”本人。。
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 4 月 29 日 16:52:04 | 显示全部楼层
;P 是不是有文件有记录的啊
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 1 日 20:56 , Processed in 0.014617 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表