MySQL Reset Root Passwd

From DawglandWiki
Jump to: navigation, search

Resetting Root User Password in MySQL/MariaDB Server

  • MUST be run as the root/super user from the Linux command line.
  • Stop MySQL/MariaDB Database Server:

# systemctl stop mysqld.service

# systemctl stop mariadb.service
  • Confirm the DB server has stopped:

# ps ax | grep sql
  • If there is an instance, do a killall mysqld_safe
  • Start MySQL Server skipping grant tables, allowing for no password logins:

# mysqld_safe --skip-grant-tables
  • Log into MySQL Database server as root user without password:

# mysql --user=root mysql
  • Reset MySQL root user password:

# update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
  • Exit MySQL and test by logging back in as root user and prompting for password:
# mysql -u root -p

Personal tools