How to change the root password in MariaDB?

To change the root password in MariaDB, you can follow these steps:

  1. Login to the terminal or console of the MariaDB database server.
  2. Run the following command to log in to MariaDB as the root user.
sudo mysql -u root
  1. Run the following command to change the password for the root user:
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

Please replace “new password” with the password you want to set.
4. Run the following command to refresh permissions and make the changes take effect:

FLUSH PRIVILEGES;
  1. Now, you can exit MariaDB.
EXIT;

After completing the above steps, you should have successfully changed the password for the root user.

bannerAds