Stop MySQL:
# service mysql-server stop
Start MySQL with --skip-grant-tables parameter:
# mysqld_safe --skip-grant-tables &
Start MySQL with -u root parameter:
# mysql -u root
Reset password:
UPDATE user SET Password=PASSWORD('[password]') WHERE User='[username]';
Restart MySQL:
# mysql-server restart
Enter with your new password:
# mysql -u root -p
Update: disable --skip-grant-tables parameter after all:
# mysql -u root -p
FLUSH PRIVILEGES;
not sure what I am doing wrong but everytime i hit enter it generates an error
root@rancid:/var/db/mysql # service mysql-server stop
Stopping mysql.
Waiting for PIDS: 12266.
root@rancid:/var/db/mysql # mysqld_safe --skip-grant-tables &
[1] 12807
root@rancid:/var/db/mysql # 2023-04-06T21:00:48.6NZ mysqld_safe Logging to '/var/db/mysql/rancid.err'.
2023-04-06T21:00:48.6NZ mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
root@rancid:/var/db/mysql # mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.40-log Source distribution
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@localhost [(none)]> UPDATE user SET Password=PASSWORD('[abcdefg]') WHERE User='[root]';
ERROR 1046 (3D000): No database selected
root@localhost [(none)]>