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
Output
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
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:
Output:
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.