mysql忘卻暗碼怎樣辦(windows linux)。本站提示廣大學習愛好者:(mysql忘卻暗碼怎樣辦(windows linux))文章只能為提供參考,不一定能成為您想要的結果。以下是mysql忘卻暗碼怎樣辦(windows linux)正文
先給年夜家引見windows下mysql忘卻暗碼的處理計劃。
Windows下的現實操作以下
1.封閉正在運轉的MySQL。
2.翻開DOS窗口,轉到mysql\bin目次。
3.輸出mysqld --skip-grant-tables回車。假如沒有湧現提醒信息,那就對了。
4.再開一個DOS窗口(由於適才誰人DOS窗口曾經不克不及動了),轉到mysql\bin目次。
5.輸出mysql回車,假如勝利,將湧現MySQL提醒符 >
6. 銜接權限數據庫>use mysql; (>是原來就有的提醒符,別忘了最初的分號)
6.改暗碼:> update user set password=password("520") where user="root"; (別忘了最初的分號)
7.刷新權限(必需的步調)>flush privileges;
8.加入 > \q
9.刊出體系,再進入,開MySQL,應用用戶名root和適才設置的新暗碼123456上岸。
第一步
C:\Documents and Settings\Administrator>cd D:\web\www.php100.com\Mysql\MySQL Se
rver5.5\bin
C:\Documents and Settings\Administrator>d:
D:\web\www.php100.com\Mysql\MySQL Server5.5\bin>mysqld --skip-grant-tables
第二步
Microsoft Windows [版本 5.2.3790]
(C) 版權一切 1985-2003 Microsoft Corp.
C:\Documents and Settings\Administrator>cd D:\web\www.php100.com\Mysql\MySQL Se
rver5.5\bin
C:\Documents and Settings\Administrator>d:
D:\web\www.php100.com\Mysql\MySQL Server5.5\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
Database changed
mysql> update user set password=password("520") where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
D:\web\www.php100.com\Mysql\MySQL Server5.5\bin>
上面給年夜家引見linux下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 ]