mysql重置root密碼

 

mysql重置root密碼


你可以按照以下簡單的五步來重置MySQL數據庫服務器密碼。第一步,停止MySQL服務器。第二步,使用–skip-grant-tables選擇啓動mysqld進程以便解除要求密碼登錄提示。第三步,以root用戶連接mysql服務器。第四步,設置一個新的mysql root用戶密碼。第五步,退出並重啓mysql服務器。以下給出每步的具體命令。

1、停止mysql服務

  /etc/init.d/mysql stop

輸出:
Stopping MySQL database server: mysqld.

2、設置忽略密碼啓動mysql服務

/usr/bin/mysqld_safe --skip-grant-tables &

輸出:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

3、使用mysql客戶端連接mysql服務器

  1. mysql -u root

輸出:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

4、設置一個新的mysql root用戶密碼

mysql> use mysql;

mysql> update user set Password=PASSWORD("輸新root密碼") where User='root';

mysql> flush privileges;

mysql> quit

5、停止mysql服務器

/etc/init.d/mysql stop

輸出:
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe –skip-grant-tables

6、啓動mysql服務器並測試

/etc/init.d/mysql start

mysql -u root -p

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章