If you are like me who tend to forget passwords almost every time, then this tip might help you reset your MySQL password just in case.
To begin, you must have access to the server, one that can stop and start the MySQL process, such as a root account. Sudo account can also be used, just as long that the user can control the MySQL service.
Begin the process by stopping the MySQL process. This can be done by executing
/etc/init.d/mysqld stop command, but this can vary depending on how you setup your server. Also, be careful of users who might be using the MySQL service as stopping the service might disrupt their work.
Once the MySQL process is killed, execute the following command:
This will run the MySQL process so you need to open another terminal to be able to reset the password. On the new terminal, you will now be able to login to MySQL to reset the password.
On the shell prompt of the new terminal, open the MySQL console:
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD(‘YOUR_NEW_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;
This will change the password for the user ‘root’. Kill the MySQL process running in the first terminal, either by killing the PID or executing CTRL+C. Then start the process again, this time with the proper procedure:
Try logging in to the MySQL console using the new password:
mysql –uroot -p
You should now be able to use the new password for your MySQL.
1 Comment to “How To Reset MySQL Password”
Subscribe to Email Feeds
- Vim: How to Copy Multiple Lines
- Required Packages for Oracle 11gR2 on Red Hat Enterprise Linux 6
- How Replace Space with Newline in Vim
- Robinson Cebu Pacific Credit Card | Your Finances on Cebu Pacific Sucks
- 12 Little Things That You As An Ateneo Hearter Can Do To Help Your Country | Yoo Jin and Akeem's Blog on Bayanihan Linux: True Blue Pinoy Linux
- [RESOLVED]Can you do this in aspx page | ASP Questions & Answers on Tip: How to Decode CSR
- How to Add or Remove Library Path in RHEL | PinoyTux Weblog on What are Libraries in Linux?
- 博文：《RHEL4 安装yum》 - 苗乡小鱼的博客 on Howto: Install yum On RHEL 4