How to Change User Password in MariaDB on Ubuntu 22.04


The last post described the procedure of creating a user in MariaDB on Ubuntu 22.04. In today’s post, we will be covering the method of changing a user’s password in MariaDB.

Setting a password for a user in MariaDB on Ubuntu is necessary for user authentication and data protection. It is a crucial security measure to prevent unauthorized access to the database and ensure accountability for user activities. Additionally, you can change this password whenever you want.

In this post, we are about to learn the method of updating or changing a user’s password in MariaDB on Ubuntu 22.04.

Changing User’s Password in MariaDB on Ubuntu 22.04

Changing a user’s password in MariaDB on Ubuntu is necessary for security, compliance, and best practices. It can maintain accountability and prevent unauthorized access to the database. Password changes may be required periodically or in case of employee turnover or shared accounts.

Here is the method of updating the user’s password in MariaDB on Ubuntu 22.04.

Step 1: Open Ubuntu’s terminal

Press “CTRL+ALT+T” to launch the Ubuntu terminal:

Step 2: Open MariaDB Shell

Utilize this command to open the MariaDB shell:

sudo mysql -u root -p

Step 3: Selecting Database

After that, select a specific database by utilizing the command below:

USE mysql;

Step 4: Create a User

If there is no existing user, then, create a new one:

CREATE USER 'sharqa'@'localhost' IDENTIFIED BY 'author';

Step 5: Change the password

To change the password, use this command:

SET PASSWORD FOR 'sharqa'@'localhost' = PASSWORD('linux@');


Note: linux@” is our new password.

Step 6: Flush Privileges

Next, type the command below in the MariaDB shell to make the changes take effect:

FLUSH PRIVILEGES;


That was all about changing a user’s password in MariaDB on Ubuntu 22.04.

Conclusion

To change the user password in MariaDB on Ubuntu 22.04, open the terminal first. After that, use the “sudo mysql -u root -p” command to open the MariaDB shell. Then, select a specific database. Next, if there is no existing user, create a new one “CREATE USER ‘sharqa’@’localhost’ IDENTIFIED BY ‘author’;”. Utilize the “SET PASSWORD FOR ‘sharqa’@’localhost’ = PASSWORD(‘linux@’);” command for changing the password. Now, make the changes take effect by using the “FLUSH PRIVILEGES;” command. That’s how you can update the user’s password in MariaDB on Ubuntu 22.04.

Print Friendly, PDF & Email
Categories