Thursday, February 13, 2020

Updating the password of a user in MySQL

Hi All,

In this post I will be giving you the hints to update the password of a user in MySql Database Server...

This is going to be a very short post, hope you like it....

There are many ways to achieve this, but the one I am going to talk about is straight forward SQL statement...

Well before you try to do what is going to be said, have the user credentials of the root user of mysql handy....

Let's start it...

This post assumes that you have the mysql database server installed and running.

Logging in as root user

Log into the database server as root

Open up a command line window and fire the command given below...

> mysql -u root -p

The above command would prompt you to key in the password, provide the one associated with the account.

You should be having the mysql prompt now to proceed...

The general form the SQL command is given below, you can change the statement and execute it accordingly...

UPDATE mysql.user SET authentication_string=PASSWORD('<password>') WHERE USER='<username>';

For Eg...

UPDATE mysql.user SET authentication_string=PASSWORD('welcome') WHERE USER='admin';

Well that is it and now you can query the database to confirm the change using the command below....

> SELECT `User`, authentication_string FROM mysql.`user` where User = '<username>';

This post is concluded here and I hope you had great time.

Thanks.


No comments:

Post a Comment

How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...