# MySQL - reset root password

DevFeed: [MySQL - reset root password](<https://devfeed.tech/articles/mysql-reset-root-password-27630.md>)

Original publisher: [Read original article](<https://gagor.pro/2015/12/mysql-reset-root-password/>)

Author: Tom

Published: 2015-12-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [MySQL](<https://devfeed.tech/topics/mysql.md>), [passwords](<https://devfeed.tech/topics/passwords.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [configuration](<https://devfeed.tech/tags/configuration.md>), [credentials](<https://devfeed.tech/tags/credentials.md>), [linux](<https://devfeed.tech/tags/linux.md>), [localhost](<https://devfeed.tech/tags/localhost.md>), [mariadb](<https://devfeed.tech/tags/mariadb.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [password](<https://devfeed.tech/tags/password.md>), [percona](<https://devfeed.tech/tags/percona.md>), [root](<https://devfeed.tech/tags/root.md>), [set](<https://devfeed.tech/tags/set.md>)

## AI overview

A tutorial explaining how to reset a MySQL user password, including the root password, by stopping MySQL, using an init file with a SET PASSWORD command, starting the server with that file, and then deleting it.

## Source excerpt

It will happen from time to time, that you're on alien machine and have to brutally update things in db without knowing credentials. Example is for root (quite secure candidate to change because it shouldn't be used in app 😃 ) but will work for any user. shutdown db service mysql stop create text file with command like this (update user accordingly) ex. in /tmp/pwchange.txt SET PASSWORD FOR "root"@"localhost" = PASSWORD("HereYourNewPassword"); start mysqld with --init-file param mysqld_safe --init-file=/tmp/pwchange.txt sometimes you may require to point configuration file ex. --defaults-file=/etc/mysql/my.cnf