mysql實現不用密碼登入的例項方法
阿新 • • 發佈:2020-09-03
具體方法:
第一步:停止mysql服務
/etc/init.d/mysqldstop
第二步:跳過密碼驗證
/usr/bin/mysqld_safe--skip-grant-tables
或
mysqld_safe--skip-grant-tables
跳過許可權表啟動mysql。
第三步:另開一個命令提示符視窗
usemysql;#刪除的記錄要insert進去,然後修改密碼 updateusersetpassword=password("new_pass")whereuser="root";
第四步:重新整理許可權
flushprivileges;
內容擴充套件:
解決MySQL不需要密碼就能登入問題
因為執行了一個更改資料庫root使用者密碼的命令,當我更改完後,發現用我新密碼和舊密碼都能登陸,於是感覺沒有輸密碼,直接回車就能登入,而我在配置中也沒有進行免密碼登陸的操作,最後,執行了一條命令解決update user set plugin = "mysql_native_password";
修改密碼及解決無密碼登陸問題都在下面命令中:
> use mysql; > update user set authentication_string=password("你的密碼") where user='root'; #(無password欄位的版本,也就是版本<=5.7的) > update user set password=password('你的密碼') where user='root'; #(有password欄位的版本,版本>5.7的) > update user set plugin="mysql_native_password"; > flush privileges; > exit;
重啟mysql服務
以上就是mysql實現不用密碼登入的例項方法的詳細內容,更多關於mysql如何實現不用密碼登入的資料請關注我們其它相關文章!