If you want to change,update or reset your MySQL account (ex: Root) password under Microsoft Windows and Unix Environment including Ubuntu, Debian, CentOS, Fedora, RedHat, Arch Linux, SUSE, … you can use one of 3 following methods below:
Method 1. Using MySQL command:
It’s my favorite way. MySQL stores all account (includes root account ) username and passwords in the user table inside the mysql database. Therefore, you can run a sql update command to update password for a particular account in the user table directly.
Note: All steps below assume you want to change password for root account.
1. Login to mysql server with command below:
[text] mysql -u root -p[/text]
Type your current root password then press Enter.
2. Run the command to update your password:
[text] mysql> update mysql.user set password=PASSWORD("NEWPASSWORD") where User=’root’;[/text]
3. Reload privileges:
[text] mysql> flush privileges;[/text]
4. Exit:
[text] mysql> exit;[/text]
5. Test your work:
[text] mysql -u root -pNEWPASSWORD[/text]
Note: there is no space between -p and NEWPASSWORD
Method 2. Using phpMyAdmin
1. Login to your phpMyAdmin Url
2. Select mysql database
3. Browser user table
4. Select an account you want to update, ex: root
5. In the edit page, type your new password in a textbox on Value column, Password row. In the dropdown list, Function column, you have to choose PASSWORD, because mySQL use the function to encrypt password for all account.
Method 3. Using mysqladmin command
If there is no password currently assigned for the root account or if you don’t have any password assigned to the root account, you can set the password with command below:
[text] mysqladmin -u root password NEWPASSWORD[/text]
Note: set the password without giving current password
However, if you want to change (or update) a root password, follow command below:
[text] mysqladmin -u root -pcurrentpass password newpass[/text]
Note: there is no space between -p and NEWPASSWORD
It assumes the your current password is currentpass and new password is newpass