Mysql找回管理員密碼

來源:互聯網
上載者:User

標籤:

我們使用MYSQL的時候有可能因為種種原因忘記ROOT密碼,如果是那樣資料庫可能就廢掉了,但是今天給大家分享下找回ROOT密碼的方法或者說是在不知道root密碼的情況下修改ROOT密碼,但是還是建議大家對root密碼謹慎保管,防止一些不必要的麻煩找回管理員密碼:

[[email protected]~]# service mysqld stop

Shutting down MySQL....[確定]

[[email protected]~]# vim /etc/init.d/mysqld

大約在283行:

      $bindir/mysqld_safe --datadir="$datadir"--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &

      wait_for_pid created "$!""$mysqld_pid_file_path"; return_value=$?

更改為

      $bindir/mysqld_safe --skip-grant-tables --skip-networking

--datadir="$datadir"--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &

      wait_for_pid created "$!""$mysqld_pid_file_path"; return_value=$?
儲存退出

mysql> use mysql

Readingtable information for completion of table and column names

You canturn off this feature to get a quicker startup with -A

 

Databasechanged

mysql> select user,host,password from user;

+---------+-----------------------+-------------------------------------------+

|user    | host                  | password                                  |

+---------+-----------------------+-------------------------------------------+

|root    | localhost             |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

|root    | localhost.localdomain |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

|root    | 127.0.0.1             |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

|tianke  | %                     |*A399693A49F7EC7C548D0FC376FA52AD293A552F |

|tianke1 | %                     |*EEAC51414F1AE247D67F47A875BDB134CF39986C |

+---------+-----------------------+-------------------------------------------+

5 rowsin set (0.01 sec)

修改root密碼

mysql> update user setpassword=password(‘123456‘)  whereuser=‘root‘;

QueryOK, 3 rows affected (0.00 sec)

Rowsmatched: 3  Changed: 3  Warnings: 0

然後將服務再次停掉,然後再將摻數改回重啟mysql即可。

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

Mysql找回管理員密碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.