lnmp重置mysql資料庫root密碼

2021-09-11 22:59:25 字數 1097 閱讀 3458

第一種方法:用軍哥的一鍵修改lnmp環境下mysql資料庫密碼指令碼

一鍵指令碼肯定是非常方便。具體執行以下命令:

wget 

sh reset_mysql_root_password.sh

方便吧!

第二種方法:通過命令修改,具體如下:

1、停止mysql服務

執行:/etc/init.d/mysql stop

1、跳過驗證啟動mysql

/usr/local/mysql/bin/mysqld_safe –skip-grant-tables >/dev/null 2>&1 &

然後:mysql mysql -uroot //登陸

mysql> use mysql;

mysql> update user set password=password(『new password』) where user=』root』;

mysql> flush privileges;

mysql> quit;

mysql5.7版本

1.停止sql服務.

執行:/etc/init.d/mysql stop

2.命令列方式啟動sql;在mysqld在mysql資料夾的bin目錄下執行

mysqld –skip-grant-table

3.直接進入root使用者,此時無需密碼

mysql -u root

4.切換到mysql資料庫中.

use mysql

5.修改密碼,5.7版本的密碼字段已經變成authentication_string了.

update mysql.user set authentication_string = password('123456') where user = 'root' and host = 'localhost';

6.重新整理下或者重啟,都可以.

flush privileges;

然後重新啟動mysql

/etc/init.d/mysql start

方法二也可以修改配置檔案:

重啟mysql就可以免密碼登入root了,當然,重設密碼後要記得把配置檔案改回去。

lnmp重置mysql資料庫root密碼

第一種方法 用軍哥的一鍵修改lnmp環境下mysql資料庫密碼指令碼 一鍵指令碼肯定是非常方便。具體執行以下命令 wget sh reset mysql root password.sh 方便吧!第二種方法 通過命令修改,具體如下 a 停止mysql服務 執行 etc init.d mysql st...

資料庫mysql重置密碼

問題重現 以下討論範圍僅限windows環境 enter password error 1045 28000 access denied for user root localhost using password yes 注 如果提示 mysql不是內部命令 需要將mysql加入環境變數,方法詳見...

MySQL忘記資料庫密碼,重置資料庫密碼

1 編輯mysql的配置檔案 my.ini 一般在mysql安裝目錄下有my.ini即mysql的配置檔案。在此配置檔案的最後新增如下一行 skip grant tables 儲存退出編輯。2 然後重啟mysql服務 在命令列下執行 net stop mysql net start mysql 3 ...