How to reset the MySQL password

Source: Internet
Author: User

  1. How to reset the MySQL password
  2. If the password is known, it is modified by the following way;
  3. [email protected]:~$ mysql --user=root--pass mysql
  4. Enter Password:
  5. MySQL> Update user set password=Password (' New-password-here ') WHERE user=' root ';
  6. Query OK, 2 rows affected (0.04 sec)
  7. Rows matched:2 Changed:2 warnings:0
  8. MySQL> Flush privileges;
  9. Query OK, 0 rows affected (0.02 sec)
  10. MySQL> Exit
  11. Bye
  12. If you forget your password, stop MySQL first and then add the parameter skip-grant-tables to restart MySQL server
  13. [Email protected]:~#/etc/init.d/mysql Stop
  14. Now your should start up the database in the background, via the Mysqld_safe command:
  15. [Email protected]:~#/usr/bin/mysqld_safe--skip-grant-tables &
  16. [1] 4271
  17. Starting mysqld daemon with databases From/var/lib/mysql
  18. MYSQLD_SAFE[6763]: Started
  19. Then log in to MySQL, change the password
  20. [email protected]:~$ mysql --user=root mysql
  21. Enter Password:
  22. MySQL> Update user set password=Password (' New-password-here ') WHERE user=' root ';
  23. Query OK, 2 rows affected (0.04 sec)
  24. Rows matched:2 Changed:2 warnings:0
  25. MySQL> Flush privileges;
  26. Query OK, 0 rows affected (0.02 sec)
  27. MySQL> Exit
  28. Bye
  29. Finally, restart MySQL server.
  30. [Email protected]:~#/etc/init.d/mysql Start
  31. Starting MySQL database Server:mysqld.
  32. Checking for corrupt, not cleanly closed and upgrade needing tables.
  33. Login with the new password to verify
  34. [email protected]:~# mysql --user=root --pass=new-password-here
  35. Welcome to the MySQL Monitor. Commands End With; or \g.
  36. Your MySQL Connection ID is 5 to server Version:5.0.24a-debian_4-log
  37. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer.
  38. MySQL> Exit
  39. Bye

How to reset the MySQL password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.