萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> linux中忘記mysql密碼找回方法

linux中忘記mysql密碼找回方法

本文章給各位同學介紹linux中忘記mysql密碼找回方法,碰到這類問題的朋友可參考參考,這裡當然是介紹忘記了root密碼了,如果其它用戶密碼,直接問root要就可以了。


0. Environment

Ubuntu 12.04 x64 server

MySQL 5.5.29

1. Steps

1.1 Modify your MySQL's "my.cnf" file, and add a line in "[mysqld]" session:
skip-grant-tables

1.2 Restart MySQL

1.3 Log in MySQL without password
$ bin/mysql -u root -p
press enter when the command shows "Enter password:"

1.4 Select database
mysql> use mysql;

1.5 Updata password
mysql> update user set password = password('mypass') where user = 'root';

1.6 Refresh tables related with system permissionmysql> flush privileges;

1.7 Modify your MySQL's "my.cnf" file to original version, delete the following line in "[mysqld]" session:skip-grant-tables

1.8 Restart MySQL

copyright © 萬盛學電腦網 all rights reserved