Skip to content

Instantly share code, notes, and snippets.

@tassoman
Forked from Artistan/.1. mysql.reset.sh
Last active December 4, 2025 11:01
Show Gist options
  • Select an option

  • Save tassoman/abdff81b40c08fcdfa530ac4ef0eca4c to your computer and use it in GitHub Desktop.

Select an option

Save tassoman/abdff81b40c08fcdfa530ac4ef0eca4c to your computer and use it in GitHub Desktop.
Reset Master (root) MySQL/MariaDB Password -- Debian
service mysql stop
mkdir -p /var/run/mysqld
chown mysql. /var/run/mysqld
/usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root < reset.sql
# do the reset.sql stuff...
killall mysqld
killall mysqld_safe
service mysql start
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypassword';
flush privileges;
quit;
# in ~/.my.cnf
[client]
user=root
password=mypassword
# now I can log in with just `mysql`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment