Reset the root password for MariaDB (or MySQL)

Submitted by donmc on Tue, 12/16/2014 - 14:26
Please note that if you haven't changed over to MariaDB - you should ... But more to the point for this post - if you need to reset your root mysql or mariadb password, the easiest way to do it on an Ubuntu platform is to run the following commands: First, you need to know what version of mysql or MariaDB you have, so run this to search for the package name: root@bazingah:/usr/local/bin# dpkg-query -S mariadb-server
mariadb-server-5.5: /usr/share/doc/mariadb-server-5.5/copyright
For MySQL users the command would be: dpkg-query -S mysql-server Once you have your package name, you can run the reconfigure command on it: (in my example, the mariadb version is 5.5, which is a match for the MySQL version that is current: "mysql-server-5.5" sudo dpkg-reconfigure mariadb-server-5.5