当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > mysql数据库root口令忘记自动恢复脚本

Unix/Linux
vi的命令
如何判断Zend Optimizer安装成功
Linux常用的日志文件和常用命令
linux如何修改主机名
linux如何删除非空文件夹|linux怎么删除非空文件夹
gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpect
vsftpd 配置例子
vsftpd 配置
vsftpd如何配置虚拟用户:PAM + PgSQL + FreeBSD-4
vsftp中文说明
VSFTP配置实例
vsftpd 配置(中)
怎么使用户能访问ftp,但不能远程登录
httpd: Could not determine the servers fully qualified domain name, using 127.0.
测试apache是否安装成功
apache 80端口无法打开|连接
make_sock: could not bind to address 0.0.0.0:443
kernel-headers下载
kernel-headers-2.2.1-4
找不到config.inc.php 没有config.inc.php这个文件

Unix/Linux 中的 mysql数据库root口令忘记自动恢复脚本


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 43 ::
收藏到网摘: n/a


大家好,最近有用户提出root口令忘记了怎么办的需求,我也在网上看到过好多这样的文章,写的都挺好的,但有些还是有问题,不是少几句话就是执行时出错。我写了一个简单的小脚本,请大家多指教吧。很简单但也很适用。 注意事项: 1。该脚本必须将属主改为root,权限为700,否则有安全问题。 2。该脚本的作用是将root用户的口令清除,若想改口令请用mysqladmin工具来做,或者进入后用update 命令也可 3。此脚本是针对系统自带的mysql命令的。如果是自己安装的源码包,可以修改关于停止mysql的那一部分。 #!/bin/sh #This is programme is recover the password of root for mysql databases. #author is coffee_45 #data is 4月 4 12:14:03 CST 2005 #kill mysqld /bin/kill `cat /var/run/mysqld/mysqld.pid` 2> /dev/null #start mysqld with special paramaters /usr/bin/safe_mysqld --skip-grant-tables & sleep 3 #change password for root chpw_mysql=/home/command_mysql echo "use mysql" >$chpw_mysql 2> /dev/null echo "update user set password=password('') where user='root';" >> $chpw_mysql 2>/dev/null echo "quit" >> $chpw_mysql mysql < $chpw_mysql /etc/init.d/mysqld restart