[MySQL]重新設定MySQL root 密碼

有關資料庫的討論, 都可以在這發表哦~~
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[MySQL]重新設定MySQL root 密碼

文章 tim »

重新設定 MySQL root 密碼
原文章出處: http://www.real-blog.com/linux-bsd-notes/531

如果忘記了 MySQL 的 root 密碼,可以透過以下方法重新設定:

1. 停止 MySQL server。

# /etc/init.d/mysql stop

2. 啟動 MySQL server,並加上 –skip-grant-tables 參數,便可以略過輸入密碼的過程:

# mysqld_safe –skip-grant-tables &

3. 用 root 連接到 MySQL server,輸入:

mysql -u root

4. 進入 MySQL server 後,輸入以下幾行 SQL 語句:
mysql> use mysql;
mysql> update user set password=PASSWORD("newpass") where User=’root’;
mysql> flush privileges;
mysql> quit

5. 重新啟動 MySQL 即可。
多多留言, 整理文章, 把經驗累積下來.....
回覆文章