MySQL Change A User Password
MySQL Change A User Password
biz/faq/mysql-change-user-password/
≡ Menu
Tutorials
BASH Shell
Troubleshooting
Nginx
Networking
MySQL
Google Cloud Platform
Amazon Cloud Computing
Rackspace Cloud Computing
Linux
CentOS
Debian / Ubuntu
Ubuntu Linux
Suse
RedHat and Friends
Slackware Linux
UNIX
AIX
Mac OS X
FreeBSD
FreeBSD Jails (VPS)
Openbsd
Solaris
See all tutorial topics
Contact us
Linux Scripting Guide
RSS/FEED
nixCraft
Linux and Unix tutorials for new and seasoned sysadmin.
I would like to change a password for a user called tom using UNIX / Linux command line option. How do I change a user password under
MySQL server?
Tutorial details
You need to use mysql (or mysql.exe on MS-Windows based system) under Linux or Difficulty Easy (rss)
Unix like operating system. Open a terminal / ssh session. Type the following Root privileges Yes (mysql admin user)
command at the shell prompt to login as a root user. The syntax is as follows for Unix Requirements mysql
like operating system:
Estimated completion time N/A
$mysql -u root -h localhost -p
OR use mysql.exe under MS-Windows host as follows (first change directory where mysql.exe is located [example: "C:\Program
Files\mysql\mysql-5.0.77-win32\bin"] ):
mysq>
1 de 4 21/10/2015 9:25
MySQL Change a User Password http://www.cyberciti.biz/faq/mysql-change-user-password/
OR
UPDATE mysql.user SET Password=PASSWORD('foobar') WHERE User='tom' AND Host='localhost';
Sample outputs:
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Feel free to replace the values for "tom" (user), "localhost" (hostname), and "foobar" (password) as per your requirements. Finally, type the
following command to reload privileges:
FLUSH PRIVILEGES;
Sample outputs:
Query OK, 0 rows affected (0.00 sec)
quit;
Sample session
2 de 4 21/10/2015 9:25
MySQL Change a User Password http://www.cyberciti.biz/faq/mysql-change-user-password/
then…
Reply Link
Keilaron February 12, 2010, 3:37 pm
Reply Link
mehari January 4, 2011, 8:08 pm
This is good
Reply Link
amazed January 27, 2011, 8:10 am
Reply Link
Zipfer October 12, 2011, 6:31 am
Reply Link
stevyn December 1, 2011, 1:35 pm
Reply Link
Re@lBanda January 25, 2012, 4:00 am
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…
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.
Reply Link
Re@lBanda January 25, 2012, 4:42 am
Forgot to mentioned….
the first single command will do the password change for local and remote which is..
Reply Link
3 de 4 21/10/2015 9:25
MySQL Change a User Password http://www.cyberciti.biz/faq/mysql-change-user-password/
I did installed a xampp and mysql don’t change the root password in this time.
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘<the_my_password'); gives Query OK, 0 rows affected.
Reply Link
mjt September 9, 2014, 4:40 am
thx alot
Reply Link
Leave a Comment
Name *
Email *
Comment
Featured Articles:
Follow Us
Like 73,232 people like this. Sign Up to see what your friends like.
©2000-2015 nixCraft. All rights reserved. Privacy Policy - Terms of Service - Questions or Comments
The content is copyrighted to nixCraft and may not be reproduced on other websites.
4 de 4 21/10/2015 9:25