導航:首頁 > 操作系統 > linux重置mysql密碼

linux重置mysql密碼

發布時間:2022-08-26 23:23:17

linux下mysql密碼忘記了怎麼辦

今天我們主要是講一下關於linux忘記mysql密碼處理方法,下面提供了5種linux忘記mysql密碼找回方法哦。
方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> update user set password=password(newpassword) where user=root;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
enter password:
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]節提供的用戶名和密碼:
# mysql -udebian-sys-maint -p
enter password:
mysql> update user set password=password(newpassword) where user=root;
mysql> flush privileges;
mysql> quit
# mysql -uroot -p
enter password:
mysql>
方法三:
這種方法我沒有進行過測試,因為我的root用戶默認密碼已經被我修改過了,那位有空測試一下,把結果告訴我,謝謝!!
# mysql -uroot -p
enter password: etc/mysql/debian.cnf文件中[client]節提供的密碼>
方法四:
方法如下: 1, 關閉mysql服務 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項, vi /etc/init.d/mysqld
方法如下:
1, 關閉mysql服務
/etc/init.d/mysqld stop
2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項,
vi /etc/init.d/mysqld
在下面運行啟動的語句里增加--skip-grant-tables
/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"
--log-error="$errlogfile" --pid-file="$mypidfile"
加入--skip-grant-tables的意思是啟動mysql服務的時候跳 過許可權表認證。啟動後,連接到mysql的root不需要口令
3,重新啟動mysql服務
/etc/init.d/mysqld start
4. 修改root用戶的密碼;
mysql> update mysql.user set password=password(123456) where user=root;
mysql> flush privileges;
mysql> quit
5. 重新啟動mysql,就可以使用 新密碼登錄了。
mysql
mysql -u root –p
輸入密碼:123456
6,關閉mysql服務
/etc/init.d/mysqld stop
7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原來不變,也就是取消--skip-grant-tables語句
8,重新 啟動mysql服務
/etc/init.d/mysqld start

㈡ 如何在Linux下重置MySQL根密碼

1、編輯/etc/my.cnf文件,在[mysqld]下面添加skip-grant-tables

2、重啟mysql服務

3、登錄mysql,mysql命令行操作對新用戶進行授權,demo如下:

GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'youpassword'WITHGRANTOPTION;
FLUSHPRIVILEGES;

4、退出mysql客戶端

5、編輯/etc/my.cnf,注釋掉添加的信息,重啟mysql後結束。

㈢ linux怎麼修改mysql密碼

1. 首先用管理員許可權登陸Linux;

2. 輸入:vi /etc/my.cnf 回車。然後按「i」鍵盤,在這個文件中的最後一行輸入:skip-grant-tables

然後按 esc鍵,然後輸入「:wq」保存並退出;

3.重啟MySQL服務
輸入:service mysqld restart回車;

4.輸入 mysql -uroot -p;

然後提示你輸入密碼,直接回車就可以進入mysql資料庫了;
開始修改MySQL用戶密碼
① 輸入use mysql回車;
② 輸入update user set password = password(「147g58」)where user=』root』;

「147g58」為你自己設置的密碼;

顯示「Query OK」這就表明修改成功了,
5.最後一步,退出mysql,將一開始修改的/etc目錄下的my.cnf文件的最後一行去掉,重啟服務;
① 輸入 exit退出mysql

② 改my.cnf文件;刪掉最後一行;

然後按ESC鍵盤,再輸入」:wq」保存退出;
③重啟服務:

就可以用你修改的密碼登錄mysql資料庫了;

㈣ 如何在Linux中重置MySQL或MariaDB root密碼

一.MySQL密碼的恢復方法之一如果忘記了MySQL的root密碼,可以用以下方法重新設置:1.切換到root下suroot2.KILL掉系統里的MySQL進程;killall-TERMmysqld3.用以下命令啟動MySQL,以不檢查許可權的方式啟動;safe_mysqld--skip-grant-tables&4.然後用空密碼方式使用root用戶登錄MySQL;mysql-uroot5.修改root用戶的密碼;mysql>updatemysql.usersetpassword=PASSWORD('123456')whereUser='root';mysql>flushprivileges;mysql>quit重新啟動MySQL,就可以使用新密碼登錄了。二.MySQL密碼的恢復方法二有可能你的系統沒有safe_mysqld程序(ubuntu操作系統,apt-get安裝的mysql),下面方法可以恢復1.切換到root下suroot2.停止mysqld;/etc/init.d/mysqlstop3.用以下命令啟動MySQL,以不檢查許可權的方式啟動;mysqld--skip-grant-tables&4.然後用空密碼方式使用root用戶登錄MySQL;mysql-uroot4.修改root用戶的密碼為123456(當然,你需要將123456改成你要設置的密碼);mysql>updatemysql.usersetpassword=PASSWORD('123456')whereUser='root';mysql>flushprivileges;mysql>quit重新啟動MySQL/etc/init.d/mysqlrestart就可以使用新密碼123456登錄了。

㈤ linux mysql 忘記密碼 怎麼修改密

初始密碼為空,使用空密碼登陸mysql執行下列語句
?
1
2
3
4
5
mysql>use mysql;
mysql> UPDATE user SET password=PASSWORD("root") WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
修改/opt/lampp/phpmyadmin/config.inc.php
找到如下代碼:
?
1
2
3
4
5
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
修改為:
?
1
2
3
4
5
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

閱讀全文

與linux重置mysql密碼相關的資料

熱點內容
台灣小公主s解壓密碼 瀏覽:566
易語言鎖機軟體源碼 瀏覽:156
迅雷下載完成無法解壓 瀏覽:592
硬碟分區命令圖解 瀏覽:443
當前雲伺服器如何關閉 瀏覽:78
mac下python在哪 瀏覽:641
廣東惠州DNS伺服器地址 瀏覽:357
編譯影片時軟體渲染錯誤 瀏覽:625
流星蝴蝶劍解壓失敗 瀏覽:294
如何確認方舟編譯器 瀏覽:664
奶粉源箱源碼什麼意思 瀏覽:178
台州程序員兼職一般去哪些網站 瀏覽:388
舊版本怎麼下載到新的安卓 瀏覽:966
flash個人網站源碼下載 瀏覽:723
javasocketbyte 瀏覽:264
素描基礎教程pdf 瀏覽:541
香港商報pdf版 瀏覽:427
安卓手機怎麼錄制吉他彈奏 瀏覽:382
ie文件夾緩存在哪裡 瀏覽:265
圍棋排名演算法 瀏覽:963