Just a little linklog to a relevant page on How to Forge. Root privileges are needed.
-
Stop service:
service mysql stop
-
Start MySQL server w/o password:
mysqld_safe --skip-grant-tables &
-
Connect to CLI client as root:
mysql -u root
-
Reset root password. Here’s the syntax for ≥v.5.7.6.
mysql> use mysql; mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("newpass"); mysql> flush privileges; mysql> quit
-
Repeat step 1, or
killall mysqld
if it doesn’t work. Output can be different on different Linux distro.service mysql start mysql -u root -p
In step 2, the ampersand &
on the right allows the task to be executed in
background.