mysql5 7修改root使用者密碼

2021-10-01 15:54:03 字數 830 閱讀 5764

首先說一下,mysql5.7跟mysql5.6及之前的版本有些不同,它的password欄位,欄位名修改為authentication_string。因此具體的修改步驟會有一些不同。

(1)設定其為免密登入

(1)

vim /etc/my.cnf

##在my.cnf的[mysqld]字段加入

skip-grant-tables

(2)##重啟mysql服務

service mysqld restart

(2)免密登入mysql

mysql

##直接回車登入

(3)將root重置密碼為空

use mysql;

update user set authentication_string=

'' where user=

'root'

;flush privileges;

(4)首先要退出mysql,刪除/etc/my.cnf檔案最後的 skip-grant-tables 重啟mysql服務,使用root使用者進行登入,因為上面設定了authentication_string為空,所以可以免密碼登入。

(5)修改密碼並設定成為所有外部ip都可使用該密碼進行連線

use mysql;

grant all on *

.* to 'root'@'%' identified by 'root使用者的密碼'

with grant option;

flush privileges;

mysql5 7 修改root 密碼

假如忘記mysql的root 密碼是什麼之後如何修改密碼 我的mysql是自己原始碼安裝的,mysql.server存放在 usr local mysql support files檔案當中 1 先關閉mysql usr local mysql support files mysql.server ...

MySql 5 7 修改root密碼

1.找到配置檔案my default.ini 然後將其開啟,可以選擇用記事本開啟 2.開啟後,搜尋mysqld關鍵字 找到後,在mysqld下面新增skip grant tables,儲存退出。ps 若提示不讓儲存時,可以將該檔案剪下到桌面,更改儲存後再複製到mysql目錄下 3.儲存後重啟mysq...

MySQL5 7修改root密碼

mysql 版本檢視 mysql version 版本在5.7以上 編輯檔案 vim etc my.cnf mysqld 下新增儲存 skip grant tables 重啟mysql服務 service mysqld restart 輸入mysql命令進入mysql命令列 修改root使用者密碼 ...