How do I change user password under MySQL server? I'd like to change a password for user called tom using UNIX / Linux command line option.
First, login to MySQL server, type following command at shell prompt to login as root
$ mysql -u root -p
2) Use mysql database (type command at mysql> prompt, do not include string "mysql>"):
mysql> use mysql;
3) Change password for user tom:
mysql> update user set password=PASSWORD("NEW-PASSWORD-HERE") where User='tom';
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -



{ 8 comments… read them below or add one }
then…
mysql> flush privileges;
Or just use the SET PASSWORD command:
http://dev.mysql.com/doc/refman/5.0/en/set-password.html
This is good
Very helpful information.
You forgot – FLUSH PRIVILEGES; after update tables
You legend. Thank you :)
Small modification in 3rd step… according to the mysql documentation, the password should be typed within single quotes instead of double quotes. But double quotes works. Refer the example below…
mysql> UPDATE user SET Password=PASSWORD(‘NEW-PASSWORD-HERE’) WHERE User=’tom’;
Another thing to mention, make sure you change the password for both the local and remote users because if a remote application server (ex-jboss) or in php connecting to mysql server it will still be needed the old password since it is remaining unchanged.
So according to this scenario the proper commands should be…
mysql> UPDATE user SET Password=PASSWORD(‘NEW-PASSWORD-HERE’) WHERE User=’tom’ AND Host=’local’;
mysql> UPDATE user SET Password=PASSWORD(‘NEW-PASSWORD-HERE’) WHERE User=’tom’ AND Host=’%';
Forgot to mentioned….
the first single command will do the password change for local and remote which is..
mysql> UPDATE user SET Password=PASSWORD(‘NEW-PASSWORD-HERE’) WHERE User=’tom’;