How to change the root password in MariaDB?
To change the root password in MariaDB, you can follow these steps:
- Login to the terminal or console of the MariaDB database server.
- Run the following command to log in to MariaDB as the root user.
sudo mysql -u root
- 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;
- Now, you can exit MariaDB.
EXIT;
After completing the above steps, you should have successfully changed the password for the root user.