mysql下忘記密碼的解決辦法

1.windows下修改MySQL密碼的方法mysql

若是在Windows下忘記了MySQL的密碼,或者從新啓動mysql服務以後丟失了密碼,能夠如今服務中中止mysql服務:sql

2.打開命令行,轉到mysql的bin目錄下;windows

代碼以下:ui

C:\Program Files\MySQL\MySQL Server 5.5\bin命令行

C:\Program Files\MySQL\MySQL Server 5.5\bin>ip

3.輸入:mysqld -nt --skip-grant-tablesinput

而後回車,若是沒有錯誤信息,就好了:it

注:skip-grant-tables參數用了以後,就能夠跳過登陸校驗;io

代碼以下:table

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqld -nt --skip-grant-tables

140317 13:23:11[Warning]option 'new':boolean value 't' wasn't recognized.Set

to OFF.

4.再打開一個命令行(由於剛纔那個DOS窗口已經不能動了),一樣轉到mysql的bin目錄下;

5.直接輸入mysql並回車,若是成功,將出現MySQL提示符>

代碼以下:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql

Welcome to the MySQL monitor.Commands end with;or \g.

Your MySQL connection id is 1
Server version: 5.5.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

6.切換到mysql表

代碼以下:mysql>USE mysql;

7.能夠修改密碼了:

代碼以下:

UPDATE user SET password=PASSWORD("123456")WHERE user="root";

8.刷新權限,不要忘記了:

代碼以下:

mysql>FLUSH PRIVILEGES;

9.退出:(退出的方法不少  有quit、exit、ctrl+c、\q等等);

10.註銷或重啓計算機,而後打開MySQL服務,使用用戶名root和設置的新密碼就能夠登錄了.

相關文章
相關標籤/搜索