MySQL密码重置,怎么办?忘记密码人之常情,那么我们该怎么办呢?密码重置分为两种,一种忘记了密码,一种记得密码。
如果知道密码,则通过以下方式修改;
gaurav@gaurav:~$mysql--user=root--passmysql
Enterpassword:
mysql>updateusersetPassword=PASSWORD('new-password-here')WHEREUser='root';
QueryOK,2rowsaffected(0.04sec)
Rowsmatched:2Changed:2Warnings:0
mysql>flushprivileges;
QueryOK,0rowsaffected(0.02sec)
mysql>exit
Bye
如果忘记密码,则先停止mysql,然后加上参数skip-grant-tables重新启动mysqlserver
root@gaurav:~#/etc/init.d/mysqlstop
Nowyoushouldstartupthedatabaseinthebackground,viathemysqld_safecommand:
root@gaurav:~#/usr/bin/mysqld_safe--skip-grant-tables&
[1]4271
Startingmysqlddaemonwithdatabasesfrom/var/lib/mysql
mysqld_safe[6763]:started
然后登陆mysql,修改密码
root@gaurav:~$mysql--user=rootmysql
Enterpassword:
mysql>updateusersetPassword=PASSWORD('new-password-here')WHEREUser='root';
QueryOK,2rowsaffected(0.04sec)
Rowsmatched:2Changed:2Warnings:0
mysql>flushprivileges;
QueryOK,0rowsaffected(0.02sec)
mysql>exit
Bye
最后重启mysqlserver就可以了。
root@gaurav:~#/etc/init.d/mysqlstart
StartingMySQLdatabaseserver:mysqld.
Checkingforcorrupt,notcleanlyclosedandupgradeneedingtables..
用新密码登陆验证下
root@gaurav:~#mysql--user=root--pass=new-password-here
WelcometotheMySQLmonitor.Commandsendwith;or\\g.
YourMySQLconnectionidis5toserverversion:5.0.24a-Debian_4-log
Type'help;'or'\\h'forhelp.Type'\\c'toclearthebuffer.
mysql>exit
Bye
¥199.00
¥798.00
¥48.00¥180.00
¥48.00¥180.00
¥199.00
¥29.90