It shouldn’t happen, but it does: I forgot my MySQL root password. Resetting is rather simple. Stop the running mysqld instance and restart it in safe mode:
# mysqld_safe --skip-grant-tables &
You can now log in as root without a password:
# mysql --user=root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 1 Server version: 5.5.35-MariaDB MariaDB Server Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> update mysql.user set Password=PASSWORD('your_new_root_password') where User='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> quit; Bye # pkill mysqld
Don’t forget restart the mysql server and clear ~/.mysql_history
afterwards!