MySQL重置root密碼

2022-08-28 03:00:16 字數 1125 閱讀 3048

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

/etc/init.d/mysql stop

輸出:stopping mysql database server: mysqld.

mysqld_safe --skip-grant-tables &

輸出:[1] 5988

starting mysqld daemon with databases from /var/lib/mysql

mysqld_safe[6025]: started

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>

mysql> use mysql;

mysql> update user set password=password("new-root-password") where user='root';

mysql> flush privileges;

mysql> quit

/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

/etc/init.d/mysql start

mysql -u root -p

mysql重置root密碼

在ubuntu 10.04上安裝了mysql,安裝時沒有要求輸入root密碼,安裝後訪問資料庫,用以下命令 mysql u root p,然後無論輸入什麼密碼都是錯誤的,只能設法重置root密碼。1.首先停止mysql服務 sudo service mysql stop 確認沒有mysql程序 ps...

mysql 重置root密碼

登入到mysql上面使用 update user set password root where user root 結果所有的root使用者的密碼的密文都變成了 root 而 root 不是真正的密碼,是加密過後的字串,所以在再次登入mysql時,使用mysql u root p 輸入密碼 roo...

mysql 重置 root 密碼

mysqld safe skip grant tables update mysql.user set authentication string password mima where user root 後沒有 password 字段 mac下安裝mysql的教程,可參考園友的文章 我安裝的版本...