PASSWORD

PASSWORD is a MySQL function used to encrypt a plain text password into a hashed value, primarily used for user password management. It returns a binary string from the plaintext password given. In more recent versions of MySQL, it is deprecated and alternative functions such as SHA2() are recommended.

Example

SELECT PASSWORD('my_password');

Output

*14E65567ABDB5135D0CFD9A70B3032C179A49EE7

Explanation

The PASSWORD() function in MySQL is used to encrypt a plaintext password. In the above example, the string ‘my_password’ is passed as an argument to the PASSWORD() function, which returns a hashed version of the password.

Example

CREATE USER new_user WITH PASSWORD 'password123';

Output

The output would not yield any result data in PostgreSQL. The command is executed successfully without any error, indicating that the user has been successfully created with the given password.

Explanation

In the example, the CREATE USER command is used to create a new user named ‘new_user’ in the PostgreSQL database. The WITH PASSWORD clause is added to set the password for ‘new_user’ as ‘password123’. If the command executes without an error, the new user is successfully created with the password specified.

Example:

CREATE USER test_user IDENTIFIED BY test_pass;

Output:

User TEST_USER created.

Explanation:

In the above example, a new user ‘test_user’ is created with password ‘test_pass’. It’s important to remember that Oracle passwords are not case sensitive. Remember to replace ‘test_user’ and ‘test_pass’ with your preferred username and password.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.