標籤:os 使用 sp on bs ad amp linux as
Windows:
1.用系統管理員登陸系統。
2.停止MySQL的服務。
3.進入命令視窗,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:mysql,進入C:mysqlbin
4.跳過許可權檢查啟動MySQL,
c:mysqlbin>mysqld-nt –skip-grant-tables
5.重新開啟一個視窗,進入c:mysqlbin目錄,設定root的新密碼
c:mysqlbin>mysqladmin -u root flush-privileges password "newpassword"
c:mysqlbin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個命令會提示你輸入新密碼,重複第一個命令輸入的密碼。
6.停止MySQL Server,用正常模式啟動Mysql
7.你可以用新的密碼連結到Mysql了。
Unix&Linux:
1.用root或者運行mysqld的使用者登入系統;
2.利用kill命令結束掉mysqld的進程;
3.使用–skip-grant-tables參數啟動MySQL Server
shell>mysqld_safe –skip-grant-tables &
4.為[email protected]設定新密碼
shell>mysqladmin -u root flush-privileges password "newpassword"5.重啟MySQL Server
GRANT ALL PRIVILEGES ON *.* TO [email protected]% IDENTIFIED BY ‘123′
linux下的解決方案:
關閉mysql
然後,safe_mysqld –skip-grant-tables
啟動mysql。
mysql -u root
mysql> use mysql
mysql> UPDATE user SET Password=PASSWORD(’xxx’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;
mysql忘記密碼怎麼辦?