linux中清空Mysql資料庫ROOT密碼教程

來源:互聯網
上載者:User

一、方法一

1)進入var/lib/mysql

2)刪除掉mysql檔案

3)重新啟動mysql ,到此密碼已經清空

4)設定新的密碼

echo "grant all on *.* to 'root'@'localhost' identified by 'newpass';" | mysql -uroot
echo "grant all on *.* to 'root'@'%' identified by 'newpass';" | mysql -uroot  -pnewpass

二、方法二

1)停止mysql服務

2)跳過許可權檢查啟動   mysql   /usr/bin/mysqld_safe   --skip-grant-tables &  (註:參數--skip-grant-tables為跳過授權表;--skip-networking為不監聽TCP/IP串連)

(4)執行MYSQL用戶端:

mysql

(5)使用mysql資料庫

use mysql;

(6)更新root密碼

update user set password='' where user='root';這裡是加一個空密碼給root;

(7)關閉mysql伺服器,用正常方試起動。

三、方法三

1)#mysql -u root -p進入mysql管理
2)mysql> set password for root@localhost=password('');
3) mysql>exit;

其實就是把它的密碼設定為空白就可以了

聯繫我們

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