更改root密碼和恢複MySQL root使用者

來源:互聯網
上載者:User

更改root密碼和恢複mysql教程 root使用者
我不小心刪除了mysql的root帳號。我該怎麼辦?"和"我失去了我的根密碼?這種問題經碰到,那麼你碰這類問題時是備份資料,重新安裝mysql和恢複所有資料庫教程檔案?還是怎麼辦,我們現在為你找到一個更好的辦法。

1、停止mysql ,
2、伺服器許可權
c:www.111cn.netbinmysqld-nt.exe --skip-grant-tables
    where c:www.111cn.net is mysql'instalation directory.
    如果是linux就如下執行命令
    /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=root --skip-networking
3、串連到伺服器使用exsisting帳戶(root或某些otherif root帳戶被刪除)。
     c:www.111cn.netbinmysql.exe -u user
     or
     /usr/local/mysql/bin/mysql -u user
    
4、更改mySQL 查詢密碼
 update mysql.user set password=password('newpwd') where user='root';
    or recreating user:
        create user root identified by password 'newpwd';
        grant all privileges on * . * to 'root'@ 'localhost' identified by 'newpwd' with grant option max_queries_per_hour 0 max_connections_per_hour 0 max_updates_per_hour 0 max_user_connections 0 ;

5、重新整理許可權
 flush privileges;

6、重新啟動伺服器
ok mysql root密碼就被你找回來了哈。

聯繫我們

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