fastread homefastrread library fastread menu

MariaDB : Change a user password

Tutorial by:      Date: 2016-04-18 05:44:56

❰ Previous Next ❱

This MariaDB tutorial explains how to change a user's password in MariaDB with syntax and examples.

Description

The SET PASSWORD statement is used to change a user's password in the MariaDB database.

Syntax

The syntax for changing a password using the SET PASSWORD statement in MariaDB is:

SET PASSWORD [ FOR user_name ] =

 {

     PASSWORD('plaintext_password1')

   | OLD_PASSWORD('plaintext_password2')

   | 'encrypted_password'

 };

Parameters or Arguments

FOR user_name

Optional. It is the user whose password you wish to change. If user_name is not specified, the password will be changed for the current user (see CURRENT_USER function).

PASSWORD('plaintext_password1')

First method to set password. Uses the PASSWORD function to take the plaintext text string found in plaintext_password1 and generate a hashed password (using newer hashing techniques).

OLD_PASSWORD('plaintext_password2')

Second method to set password. Uses the OLD_PASSWORD function to take the plaintext text string found in plaintext_password2 and generate a hashed password (using older hashing techniques).

encrypted_password

Third method to set password. A password that is already encrypted using the authentication method for the user account that does not need to be modified any further.

Note

  • The FOR user_name parameter must be specified in the format of user_name@host_name, such as 'fastread.aitechtonic'@'localhost'.

Example

Let's look at an example that shows how to use the SET PASSWORD statement in MariaDB.

For example, if you wanted to update the user named fastread.aitechtonic with the password 'newpassword', you would run the following SET PASSWORD statement in MariaDB:

SET PASSWORD FOR 'fastread.aitechtonic'@'localhost' = PASSWORD('newpassword');

If you wanted to reset the password using the older hashing techniques using the OLD_PASSWORD function, you would modify the SET PASSWORD statement as follows:

SET PASSWORD FOR 'fastread.aitechtonic'@'localhost' = OLD_PASSWORD('newpassword');

If the new password was already encrypted, you could use the SET PASSWORD statement as follows:

SET PASSWORD FOR 'fastread.aitechtonic'@'localhost' = '*0886644237EED5C45BE221093802B5AB0C06D2D0';

 

❰ Previous Next ❱


MariaDB

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website