Mysql 5 7 忘記密碼或重置密碼

2021-07-27 08:04:56 字數 642 閱讀 7204

mysql 5.7 mysql庫的user表中已經不再有password欄位,取而代之的為authentication_string

修改語法相同,步驟也相同。

注意:/etc/my.cnf這個配置檔案中,

basedir、datadir這兩個引數的指向,如果指向錯誤,mysqld_safe --skip-grant-tables啟動沒有mysql庫。

[mysql@guoqing ~]$ service mysqld stop    #停止mysql服務

[mysql@guoqing ~]$ mysqld_safe --skip-grant-tables &  #以不啟用grant-tables模式啟動mysql

[mysql@guoqing ~]$ mysql -uroot -p -h127.0.0.1 #輸入命令回車進入,出現輸入密碼提示直接回車。

mysql>update mysql.user set authentication_string= password ('guo') where user='root'; #更改密碼為 guo

mysql>flush privileges; #更新許可權

mysql>quit #退出

service mysql start

重新登入即可使用新密碼。

重置mysql5 7密碼

其實想要重置 5.7 的密碼很簡單,就一層窗戶紙 1 修改 etc my.cnf,在 mysqld 小節下新增一行 skip grant tables 1 這一行配置讓 mysqld 啟動時不對密碼進行驗證 2 重啟 mysqld 服務 systemctl restart mysqld 3 使用 r...

mysql 5 7 忘記密碼

作業系統為centos7 64 1 修改 etc my.cnf,在 mysqld 小節下新增一行 skip grant tables 1 這一行配置讓 mysqld 啟動時不對密碼進行驗證 2 重啟 mysqld 服務 systemctl restart mysqld 3 使用 root 使用者登入...

mysql5 7 安裝重置密碼

開啟乙個終端視窗 輸入 sudo usr local mysql support files mysql.server stop 我的是 mac這個輸入時沒找到檔案,但不會影響後續操作 輸入 sudo usr local mysql bin mysqld safe skip grant tables...