Start 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.
1 |
UPDATE user SET `authentication_string` = PASSWORD('myNewPassword') WHERE `User` = 'root'; |
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.