MySQL5.7重置root密碼

如下步驟若是添加了MySQL的環境變量,則能夠直接運行mysql有關命令,不然必須到mysql安裝目錄的bin目錄下操做。
步驟以下:
1.中止mysql服務(以管理員身份,在cmd命令行下運行) net stop mysql
2.使用 mysqld –skip-grant-tables 命令啓動mysql數據庫
D:\>net stop mysql MySQL 服務正在中止. MySQL 服務已成功中止。
D:\>mysqld --skip-grant-tables
 mysql

3.不關閉以上窗口,新開一個cmd窗口,輸入mysql -u root,直接按回車鍵
D:\>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.26-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer.sql


更改密碼: update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';數據庫

*特別提醒注意的一點是,新版的mysql數據庫下的user表中已經沒有Password字段了加密

而是將加密後的用戶密碼存儲於authentication_string字段命令行

修改完畢。重啓ip

相關文章
相關標籤/搜索