mysql中如何重置数据库密码?
当前位置:以往代写 > 数据库教程 >mysql中如何重置数据库密码?
2019-06-14

mysql中如何重置数据库密码?

mysql中如何重置数据库密码?

  MySQL密码重置,怎么办?忘记密码人之常情,那么我们该怎么办呢?密码重置分为两种,一种忘记了密码,一种记得密码。

mysql中如何重置数据库密码?_数据库_数据库密码重置_课课家

  如果知道密码,则通过以下方式修改;

  [email protected]:~$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

  [email protected]:~#/etc/init.d/mysqlstop

  Nowyoushouldstartupthedatabaseinthebackground,viathemysqld_safecommand:

  [email protected]:~#/usr/bin/mysqld_safe–skip-grant-tables&

  [1]4271

  Startingmysqlddaemonwithdatabasesfrom/var/lib/mysql

  mysqld_safe[6763]:started

  然后登陆mysql,修改密码

  [email protected]:~$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就可以了。

  [email protected]:~#/etc/init.d/mysqlstart

  StartingMySQLdatabaseserver:mysqld.

  Checkingforcorrupt,notcleanlyclosedandupgradeneedingtables..

  用新密码登陆验证下

  [email protected]:~#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

    关键字:

在线提交作业