導航:首頁 > 操作系統 > linux下mysql忘記密碼

linux下mysql忘記密碼

發布時間:2023-03-28 01:42:38

linux下MySQL忘記root密碼怎麼辦

你好,方法如下:
一. MySQL密碼的恢復方法之一衫喚滲
如果忘記了MySQL的root密碼,可以用以下方法重新設置:
1. KILL掉系統里的MySQL進程;
killall -TERM mysqld
2. 用以下命令啟動MySQL,以不檢查許可權的方式啟動;
safe_mysqld --skip-grant-tables &
3. 然後用空密碼方式使用root用戶登錄 MySQL;
mysql -u root
4. 修改root用戶的密碼;
mysql> update mysql.user set password=PASSWORD('新密碼') where User='root';
mysql> flush privileges;
mysql> quit
重新啟動MySQL,就可以使用新密碼登錄了。
二. MySQL密碼的恢復方法二
有可能你的系統沒有 safe_mysqld 程序(比如我現在用的 ubuntu操作系統, apt-get安鏈檔裝的mysql) , 下面方法可以恢復
1. 停止mysqld;
/etc/init.d/mysql stop
(您可能有其它的方法,總之停止mysqld的運行就可以了)

2. 用或脊以下命令啟動MySQL,以不檢查許可權的方式啟動;
mysqld --skip-grant-tables &
3. 然後用空密碼方式使用root用戶登錄 MySQL;

❷ Linux下MySQL忘記root密碼怎麼辦

inux下mysql的root密碼忘記解決方法:

1.首先確認伺服器出於安全的狀態,也就是沒有人能夠任意地連接MySQL資料庫。
因為在重新設置MySQL的root密碼的期間,MySQL資料庫完全出於沒有密碼保護的
狀態下,其他的用戶也可以任意地登錄和修改MySQL的信息。可以採用將MySQL對
外的埠封閉,並且停止Apache以及所有的用戶進程的方法實現伺服器的准安全
狀態。最安全的狀態是到伺服器的Console上面操作,並且拔掉網線。
2.修改MySQL的登錄設置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存並且退出vi。
3.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登錄並修改MySQL的root密碼
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.將MySQL的登錄設置修改回來
# vi /etc/my.cnf
將剛才在[mysqld]的段中加上的skip-grant-tables刪除
保存並且退出vi。
6.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

❸ Linux下MySQL忘記root密碼怎麼辦

首先停掉MySQL服務:
sudo service mysql stop
以上命令適用於Ubuntu和Debian。CentOS、Fedora和RHEL下使用mysqld替換mysql。

以衡余拆安全模式啟動mysql:

sudo mysqld_safe --skip-grant-tables --skip-networking &
--skip-networking,禁止遠程無密碼登錄MySQL。

無密碼登錄:
mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("mynewpassword") where User='root';
mysql> flush privileges;
接著退出,重啟毀型Mysql:
mysql > quit

現在可以用咐棗新密碼登錄了:
mysql -u root -p

❹ linux下mysql忘記密碼怎麼辦

如果不是root密碼:用root進去,修改mysql資料庫user表岩宴咯。

如果是root密碼:

方法一:
MySQL提供跳過訪問控制的命令行參數,通過在命令行以此命令啟動MySQL伺服器:
safe_mysqld --skip-grant-tables&
即可跳過MySQL的訪問粗卜銀控制,任何人都可以在控制台以管理員的身份進入弊兆MySQL資料庫。
需要注意的是在修改完密碼以後要把MySQL伺服器停掉重新啟動才會生效

❺ 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忘記密碼相關的資料

熱點內容
c需要pdf 瀏覽:865
超級解壓的美甲 瀏覽:72
安卓手機如何永久取消靜音 瀏覽:722
appstore免密碼支付怎麼關閉 瀏覽:30
域控制器如何備份到另一伺服器 瀏覽:306
騰訊雲應用伺服器可以做什麼 瀏覽:507
二次元表格編程 瀏覽:20
plc編程器保停 瀏覽:963
如何降低伺服器的內存佔用率 瀏覽:868
阿里雲伺服器是個什麼意思 瀏覽:817
國內最好的數控編程培訓學校 瀏覽:13
222乘104列是演算法 瀏覽:159
程序員溝通正確姿勢 瀏覽:969
魔玩app怎麼視頻推廣 瀏覽:960
程序員抽獎送禮 瀏覽:458
北京java程序員薪資 瀏覽:658
如何創建網路平台或者app 瀏覽:356
python隨機數生成控制概率 瀏覽:237
壓縮機並聯運行 瀏覽:901
兩位單片機 瀏覽:64