Problem
User wants to reset the MySQL server username / password
Solution
Stop the mysql server
systemctl stop mysqld
create file reset_pass.sql
add the following line to the file ( change password according to your needs )
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPassword123';
if you logged in as root run the following command to execute the SQL command
mysqld --user=root --init-file=./reset_pass.sql &
mysql user
mysqld --init-file=./reset_pass.sql &
Start the MySQL Server
systemctl start mysqld
and delete the file reset_pass.sql
rm -f reset_pass.sql
Attachment: commands.txt
We do this for a living.
Kubernetes, DevOps and platform engineering, delivered in days — not another weekend lost to a stack trace.
Start a project →