如果有一天你忘記了root的密碼,我們可以利用 --skip-grant-tables這個引數,具體實施如下:
[root@he1 bin]# mysql -uroot -p
enter password:
error 1045 (28000):access denied for user 'root'@'localhost' (using password: yes)
[root@he1 bin]# ps-ef|grep mysql
root 7572 2398 0 00:58 pts/1 00:00:00 /bin/sh ./mysqld_safe--defaults-file=/etc/my.cnf
mysql 8199 7572 0 00:58 pts/1 00:00:00 /usr/local/mysql/bin/mysqld--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin --user=mysql--log-error=/data/mysql/error.log --open-files-limit=3072--pid-file=/data/mysql/he1.pid --socket=/data/mysql.sock --port=3306
root 8230 2398 0 00:59 pts/1 00:00:00 grep mysql
[root@he1 bin]# kill -9 8199 7572
[root@he1 bin]# ps-ef|grep mysql
root 8232 2398 0 00:59 pts/1 00:00:00 grep mysql
[1]+ killed ./mysqld_safe--defaults-file=/etc/my.cnf
[root@he1 bin]# ps-ef|grep mysql
root 8234 2398 0 00:59 pts/1 00:00:00 grep mysql
[root@he1 bin]# ./mysqld_safe --defaults-file=/etc/my.cnf--skip-grant-tables &
[1] 8235
[root@he1 bin]#160317 00:59:43 mysqld_safe logging to '/data/mysql/error.log'.
160317 00:59:43mysqld_safe starting mysqld daemon with databases from /data/mysql
[root@he1 bin]# mysql -uroot
welcome to the mysqlmonitor. commands end with ; or \g.
your mysqlconnection id is 1
server version:5.6.16-log mysql community server (gpl)
oracle is aregistered trademark of oracle corporation and/or its
affiliates. othernames may be trademarks of their respective
owners.
type 'help;' or '\h'for help. type '\c' to clear the current input statement.
mysql> quit
bye[root@he1 bin]#mysql
welcome to the mysqlmonitor. commands end with ; or \g.
your mysqlconnection id is 2
server version:5.6.16-log mysql community server (gpl)
oracle is aregistered trademark of oracle corporation and/or its
affiliates. othernames may be trademarks of their respective
owners.
type 'help;' or '\h'for help. type '\c' to clear the current input statement.
mysql> quit
bye本文中採用kill-9的方式,這種方式不建議在生產庫中使用,生產庫中應採用正常停庫
mysql 怎麼辦 mysql 密碼忘記怎麼辦
一 若資料庫是初次登陸 linux系統給資料庫生成了乙個原始密碼在檔案 var log mysqld.log中 grep temporary password var log mysqld.log 找到原始密碼 登陸 mysql uroot p 你找到的密碼 mysql set global val...
mysql忘記密碼怎麼辦?
mysql忘記密碼怎麼辦?windows 1.用系統管理員登陸系統。2.停止mysql的服務。3.進入命令視窗,然後進入mysql的安裝目錄,比如我的安裝目錄是c mysql,進入c mysqlbin 4.跳過許可權檢查啟動mysql,c mysqlbin mysqld nt skip grant ...
mysql忘記密碼怎麼辦
1.關閉正在執行的mysql。2.開啟dos視窗,轉到mysql bin目錄。3.輸入mysqld skip grant tables回車。如果沒有出現提示資訊,那就對了。4.再開乙個dos視窗 因為剛才那個dos視窗已經不能動了 轉到mysql bin目錄。5.輸入mysql回車,如果成功,將出現...