Mysql5.6忘记root密码修改root密码的方法
mysql5.6忘记数据库的root密码:
[root@oraserver139~]#mysql-uroot-p
Enterpassword:
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)
查看当前安装的mysql版本:
root@oraserver139~]#rpm-qa|grepMySQL
MySQL-server-5.6.15-1.el6.x86_64
MySQL-client-5.6.15-1.el6.x86_64
MySQL-shared-compat-5.6.15-1.el6.x86_64
MySQL-devel-5.6.15-1.el6.x86_64
perl-DBD-MySQL-4.022-1.el6.rfx.x86_64
停止mysql服务:
[root@oraserver139~]#servicemysqlstop
ShuttingdownMySQL..SUCCESS!
进入到skip-grant-tables模式:
[root@oraserver139~]#mysqld_safe--skip-grant-tables
14021115:37:49mysqld_safeLoggingto'/var/lib/mysql/oraserver139.err'.
14021115:37:49mysqld_safeStartingmysqlddaemonwithdatabasesfrom/var/lib/mysql
现在就不需要密码就可以进入mysql了:
[root@oraserver139~]#mysql
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis1
Serverversion:5.6.15MySQLCommunityServer(GPL)
Copyright(c)2000,2013,Oracleand/oritsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
进入mysql系统数据库:
mysql>usemysql
Readingtableinformationforcompletionoftableandcolumnnames
Youcanturnoffthisfeaturetogetaquickerstartupwith-A
Databasechanged
修改root账户密码:
mysql>updateusersetpassword=password("12345")whereuser="root";
QueryOK,4rowsaffected(0.02sec)
Rowsmatched:4Changed:4Warnings:0
刷新权限:
mysql>flushprivileges;
QueryOK,0rowsaffected(0.00sec)
mysql>exit
Bye
停止mysql进程:
[1]+Stoppedmysqld_safe--skip-grant-tables
启动mysql:
[root@oraserver139~]#servicemysqlstart
StartingMySQLSUCCESS!
使用刚才修改的密码进入mysql:
[root@oraserver139~]#mysql-uroot-p12345
Warning:Usingapasswordonthecommandlineinterfacecanbeinsecure.
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis3
Serverversion:5.6.15
Copyright(c)2000,2013,Oracleand/oritsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>showdatabases;
ERROR1820(HY000):YoumustSETPASSWORDbeforeexecutingthisstatement
mysql>SETPASSWORD=PASSWORD('12345');
QueryOK,0rowsaffected(0.00sec)
mysql>showdatabases;
+--------------------+
|Database|
+--------------------+
|information_schema|
|mysql|
|performance_schema|
|test|
+--------------------+
4rowsinset(0.00sec)
修改完成;
以上所述是小编给大家介绍的Mysql5.6忘记root密码修改root密码的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!