1. Find the mariadb configuration file.
Command: Find/-name my. CNF
Note: generally in/etc/My. CNF
2. modify the configuration file
Add one line in the [mysqld] configuration of the mariadb configuration file/etc/My. CNF: Skip-grant-tables
#===================================================== ======================
[Mysqld]
Datadir =/var/lib/MySQL
Socket =/var/lib/MySQL. Sock
Skip-grant-tables # Note: This line is inserted.
# Disabling symbolic-links is recommended to prevent assorted Security Risks
Symbolic-links = 0
# Settings user and group are ignored when then EMD is used.
# If you need to run mysqld under a different user or group,
# Customize your every EMD unit file for mariadb according to
# Instructions in http://fedoraproject.org/wiki/Systemd
[Mysqld_safe]
Log-error =/var/log/mariadb. Log
PID-file =/var/run/mariadb. PID
Skip-grant-tables
#
# Include all files from the config directory
#
! Includedir/etc/My. CNF. d
#===================================================== ======================
3. Use SQL to change the root password
[[Email protected] ~] $ Mysql
Mariadb [MySQL]> Update user SET Password = PASSWORD ('100) where user = 'root ';
Query OK, 4 rows affected (0.03 Sec)
Rows matched: 4 changed: 4 Warnings: 0
Mariadb [MySQL]> flush privileges;
Query OK, 0 rows affected (0.01 Sec)
Mariadb [MySQL]> exit
4. Complete. Cancel password-free logon and restart mariadb.
5. Attach commands related to mariadb.
Query status: systemctl status mariadb
Disable: systemctl status mariadb
Enable: systemctl stop mariadb
Restart: systemctl restart mariadb
Maria forgot password