關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 重新設定 MySQL root 密碼

    Posted on January 26th, 2009 Sam Tang No comments

    如果忘記了 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 即可。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word