How to reset MySQL/MariaDB root password

mysql-logo-imageStart session ssh (using root if possible).

Edit my.cnf file using.

sudo vi /etc/my.cnf

Add line to [mysqld] block:

skip-grant-tables

Save and exit.

Restart MySQL service.

service mysql restart

OR you can start MySQL/MariaDB with:
mysqld_safe --skip-grant-tables &

Connect to MySQL/MariaDB console:

mysql

Using main database.

use mysql;

Redefine user root password.

Edit file my.cnf.

sudo vi /etc/my.cnf

Erase line.

skip-grant-tables

Save and exit.

Restart MySQL service:

service mysqld restart

Check service status.

service mysql status

Connect to database.

mysql -u root -p

Type new password when prompted.

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com