當前位置:首頁 » 操作系統 » mysqlroot密碼忘記linux

mysqlroot密碼忘記linux

發布時間: 2024-06-28 23:12:29

A. linux 安裝好mysql 怎麼查看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: <輸入新設的密碼newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]節提供的用戶名和密碼:
# mysql -udebian-sys-maint -p
enter password: <輸入[client]節的密碼>
mysql> update user set password=password(newpassword) where user=root;
mysql> flush privileges;
mysql> quit
# mysql -uroot -p
enter password: <輸入新設的密碼newpassword>
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

B. linux mysql密碼忘了怎麼辦

Windows:
1.以系統管理員身份登陸系統。
2.打開cmd-----net start 查看mysql是否啟動。啟動的話就停止net stop mysql.
3.我的mysql安裝在d:\usr\local\mysql4\bin下。
4.跳過許可權檢查啟動mysql.
d:\usr\local\mysql\bin\mysqld-nt --skip-grant-tables
5.重新打開cmd。進到d:\usr\local\mysql4\bin下:
d:\usr\local\mysql\bin\mysqladmin -u root flush-privileges password "newpassword"
d:\usr\local\mysql\bin\mysqladmin -u root -p shutdown 這句提示你重新輸密碼。
6.在cmd里net start mysql
7.搞定了。
Linux:
MySQL root密碼的恢復方法之一
如果忘記了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,就可以使用新密碼登錄了。

C. linux mysql瀵嗙爜蹇樹簡鎬庝箞鍔

1錛庨栧厛紜璁ゆ湇鍔″櫒鍑轟簬瀹夊叏鐨勭姸鎬侊紝涔熷氨鏄娌℃湁浜鴻兘澶熶換鎰忓湴榪炴帴MySQL鏁版嵁搴撱
鍥犱負鍦ㄩ噸鏂拌劇疆MySQL鐨剅oot瀵嗙爜鐨勬湡闂達紝MySQL鏁版嵁搴撳畬鍏ㄥ嚭浜庢病鏈夊瘑鐮佷繚鎶ょ殑
鐘舵佷笅錛屽叾浠栫殑鐢ㄦ埛涔熷彲浠ヤ換鎰忓湴鐧誨綍鍜屼慨鏀筂ySQL鐨勪俊鎮銆傚彲浠ラ噰鐢ㄥ皢MySQL瀵
澶栫殑絝鍙e皝闂錛屽苟涓斿仠姝Apache浠ュ強鎵鏈夌殑鐢ㄦ埛榪涚▼鐨勬柟娉曞疄鐜版湇鍔″櫒鐨勫噯瀹夊叏
鐘舵併傛渶瀹夊叏鐨勭姸鎬佹槸鍒版湇鍔″櫒鐨凜onsole涓婇潰鎿嶄綔錛屽苟涓旀嫈鎺夌綉綰褲
2錛庝慨鏀筂ySQL鐨勭櫥褰曡劇疆錛
# vi /etc/my.cnf
鍦╗mysqld]鐨勬典腑鍔犱笂涓鍙ワ細skip-grant-tables
渚嬪傦細
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
淇濆瓨騫朵笖閫鍑簐i銆
3錛庨噸鏂板惎鍔╩ysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4錛庣櫥褰曞苟淇鏀筂ySQL鐨剅oot瀵嗙爜
# /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]鐨勬典腑鍔犱笂鐨剆kip-grant-tables鍒犻櫎
淇濆瓨騫朵笖閫鍑簐i銆
6錛庨噸鏂板惎鍔╩ysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
Work for fun,Live for love!

D. linux下mysql忘記密碼的解決方法

問題如下:輸入命令mysql
-uroot
-p,但是密碼忘了。
第一步:停止mysql服務
網上有給出方法打開/etc/my.cnf,在裡面修改,但是我壓根沒在這個目錄下找到該文件。可能版本原因吧!
輸入命令停止mysql服務:/etc/init.d/mysql
stop
第二步:安全啟動mysql,且跳過授權表:mysqld_safe
--user=mysql
--skip-grant-tables
--skip-networking
&
第三步:重新設置mysql密碼
輸入:mysql
-uroot
-p,此時不用輸密碼,直接按回車就可以進去。
輸入語句:use
mysql,即選擇一個資料庫,輸入重設密碼的語句,我發現如下的問題,這說明password這一列,不在其中
所以應當修改的是authentication_string這一列
之後輸入命令:flush
privileges,用來刷新mysql的系統許可權相關表。quit退出mysql
第四步:重啟服務,輸入新設置的密碼登錄
重啟mysql服務:/etc/init.d/mysql
restart
輸入密碼,進入mysql即可。
更多內容請查看專題:MySQL密碼操作匯總
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:MySQL忘記密碼恢復密碼的實現方法mysql修改用戶密碼的方法和mysql忘記密碼的解決方法強制修改mysql的root密碼的六種方法分享(mysql忘記密碼)linux
mysql忘記密碼的多種解決或Access
denied
for
user
''root''@''localhost''MySql登陸密碼忘記及忘記密碼的解決方案mysql
忘記密碼的解決方法(linux和windows小結)mysql忘記密碼怎麼辦mysql忘記密碼的解決方法Windows中MySQL
root用戶忘記密碼解決方案mysql資料庫忘記密碼時如何修改

熱點內容
文件夾快速訪問點不開 發布:2024-07-01 05:22:29 瀏覽:66
掌訊方案安卓導航怎麼改善音質 發布:2024-07-01 05:07:33 瀏覽:528
怎麼在伺服器裡面發彈幕 發布:2024-07-01 04:44:03 瀏覽:572
shell腳本內存 發布:2024-07-01 04:41:13 瀏覽:356
手機配置低怎麼打王者順暢 發布:2024-07-01 04:32:21 瀏覽:826
編程的術語 發布:2024-07-01 03:44:22 瀏覽:233
七牛雲存儲許式偉 發布:2024-07-01 03:32:53 瀏覽:945
河南聯通伺服器ip地址 發布:2024-07-01 03:23:25 瀏覽:267
倉儲貨架配置因素有哪些 發布:2024-07-01 03:14:45 瀏覽:341
python27下載linux 發布:2024-07-01 03:12:05 瀏覽:72