linux忘記mysql密碼找回方法

來源:互聯網
上載者:User

linux忘記mysql教程密碼找回方法
今天我們主要是講一下關於linux忘記mysql密碼處理方法,下面提供了5種linux忘記mysql密碼找回方法哦。
方法一:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> update user set password=password('newpassword') where user='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
enter password: <輸入新設的密碼newpassword>
mysql>

方法二:
直接使用/etc/mysql/debian.cnf檔案中[client]節提供的使用者名稱和密碼:

# mysql -udebian-sys-maint -p
enter password: <輸入[client]節的密碼>
mysql> update user set password=password('newpassword') where user='root';
mysql> flush privileges;
mysql> quit
# mysql -uroot -p
enter password: <輸入新設的密碼newpassword>
mysql>

方法三:
這種方法我沒有進行過測試,因為我的root使用者預設密碼已經被我修改過了,那位有空測試一下,把結果告訴我,謝謝!!

# mysql -uroot -p
enter password: <輸入/etc/mysql/debian.cnf檔案中[client]節提供的密碼>


方法四

方法如下: 1, 關閉mysql服務 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld指令碼啟動位置增加此選項, vi /etc/init.d/mysqld
方法如下:

1, 關閉mysql服務
/etc/init.d/mysqld stop

2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld指令碼啟動位置增加此選項,
vi /etc/init.d/mysqld

在下面運行啟動的語句裡增加--skip-grant-tables
/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"
--log-error="$errlogfile" --pid-file="$mypidfile"

加入--skip-grant-tables的意思是啟動mysql服務的時候跳 過許可權表認證。啟動後,串連到mysql的root不需要口令

3,重新啟動mysql服務
/etc/init.d/mysqld start

4. 修改root使用者的密碼;

mysql> update mysql.user set password=password('123456') where user=root;
mysql> flush privileges;
mysql> quit

5. 重新啟動mysql,就可以使用 新密碼登入了。

mysql

mysql -u root –p
輸入密碼:123456

6,關閉mysql服務
/etc/init.d/mysqld stop

7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原來不變,也就是取消--skip-grant-tables語句
8,重新 啟動mysql服務

/etc/init.d/mysqld start
unix

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.