Home

How to Reset MySQL root’s Password

ไม่ได้เข้าไปใช้ MySQL บนเว็บเซิร์ฟเวอร์ที่ทำงานนานจัด จำพาสเวิร์ดของ root ไม่ได้ เลยต้อง google หาวิชามารซะงั้น..

(จดไว้ก่อน เผื่อต้องทำอีก :em02: )

  1. stop MySQL server โดยสั่งใน Services หรือ พิมพ์ net stop mysql ใน Command Prompt
  2. start MySQL server โดยใส่ออพชัน —skip-grant-tables

    mysqld-nt —skip-grant-tables

    ถ้าสตาร์ทไม่ขึ้น อาจต้องใส่ออพชัน —defaults-file เข้าไปด้วย

    mysqld-nt —skip-grant-tables —defaults-file=”C:\WINDOWS\my.ini”

  3. connect เข้า MySQL ด้วย user root

    mysql -u root

  4. ตั้งพาสเวิร์ดใหม่ให้ root โดยพิมพ์คำสั่ง

    mysql> use mysql; mysql> update user set password=PASSWORD(“newpassword”) where user=’root’; mysql> flush privileges; mysql> quit

  5. stop MySQL server อีกรอบ
  6. start MySQL server ตามปกติ แล้วลองเทสต์ด้วยการล็อกอินเป็น root

    mysql -u root -p

เท่านี้ก็เรียบร้อย :em05:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options