How can the root password be changed in MariaDB?

To change the root password of MariaDB, you can follow these steps: 1. Open a terminal or command prompt window, and log in to the MariaDB server using the root user. 2. Enter the following command to access the MariaDB command line interface.

mysql -u root -p

3. Enter the current root password and press the Enter key.
4. Run the following command to change the root password:

ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

‘New password’ is the new password you wish to set, which can be changed as needed. 5. Run the following command to refresh permissions:

FLUSH PRIVILEGES;

Exit the MariaDB command-line interface:

exit;

You have successfully changed the root password for MariaDB. Please log in next time using the new password.

bannerAds