I'm trying to work out how to reset the root
mySQL users password. I've found:
https://www.tecmint.com/reset-root-password-in-mysql-8/
I tried the first option, and at first it appears to work:
root@admin:~# cat /tmp/init-file.txt
ALTER USER 'root'@'localhost' IDENTIFIED BY 'testPASS';
root@admin:~#
Then I run:
root@admin:~# mysqld --user=mysql --init-file=/tmp/init-file.txt --console
root@admin:~#
Yet when I try and now login with the new password, I get:
root@admin:~# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
What am I doing wrong? I've never had to reset the root password before, so I'm not sure if I'm missing something silly
UPDATE: Interstingly, even though I'm doing "service mysql stop", it does seem like its still running:
root 4992 0.0 0.0 52700 3904 pts/0 S 15:33 0:00 sudo mysqld_safe --skip-grant-tables
root 4993 0.0 0.0 4504 1720 pts/0 S 15:33 0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql 5580 1.1 15.8 10668984 1291760 pts/0 Sl 15:33 0:10 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mysql/error.log --open-files-limit=2048 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
How would I go about killing it fully?
UPDATE 2:
Even after making sure mysql is fully closed, it still doesn't seem to work:
root@admin:~# mysqld --user=mysql --init-file=/tmp/init-file.txt --console
root@admin:~# service mysql start
root@admin:~# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I've even tried a "flush" in the file to reset passwords:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxx';
flush privileges;