Practicalweb Ltd

Technical information on this site may be out of date : no updates since 2015

Ubuntu Mysql Root password reset (init file not found)

October 9 2015 : posted under mysql

If you don’t use the mysql root account very often and change passwords reasonably frequently you may (like me) find that you no longer know the mysql root password on a dev box.

The mysql site has a reasonable guide here

But there always seems to be something additional, this time for me it was apparmor preventing mysql from reading my reset file

to reset I had to look in /etc/apparmor.d/usr.sbin.mysqld and identify /etc/mysql/conf.d/ as a good place to place a reset init file

sudo su
service stop mysql
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');" > /etc/mysql/conf.d/mysql-init
mysqld_safe --init-file=/etc/mysql/conf.d/mysql-init &
# check password works
# stop mysql
service start mysql
rm /etc/mysql/conf.d/mysql-init