Linux下快速重設MySQL使用者(root)密碼方法

來源:互聯網
上載者:User

  今日公司購買了一台美國VPS,Linux作業系統,通過Container進行管理,系統預裝了MYSQL,密碼是隨機產生的(聯絡那邊技術員,為得到滿意結果)只好想辦法重設MYSQL密碼了。

  重設MYSQL的root密碼的方法:

  1.停止正在啟動並執行MySQL進程

  killall -TERM mysqld

  2.以安全模式啟動MySQL

  mysqld_safe –skip-grant-tables &

  3.登陸MYSQL,完成上述兩步以後就可以不用密碼進入MySQL了

  mysql -u root

  4.更改密碼, 到此我們就可以在mysql用戶端提示符下直接修改使用者資訊表了

  use mysql;

  select host, user, password from user;

  update user set password=password(“新密碼”) where user=”root”

  flush privileges;

  第一句:開啟系統資料庫“mysql”

  第二句:查看一下目前使用者資訊表有哪 些使用者都可以從哪個主機訪問資料

  第三句:直接修改使用者密碼,第四句是更新使用者權限使其立即生效

  5.退出控制台,啟動服務

  killall -TERM mysqld

  service mysqld start

  通過上述方法我成功重設了MYSQL的root密碼

相關文章

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.