Hi,
a different approach:
stop mysql
start the daemon manually skipping the grant tables
mysqld --skip-grant-tables
No connect to mysql with
mysql -h localhost mysql
and do something like
A)
use mysql;
update user set Password = PASSWORD('thepass') where User='root';
flush privileges;
Then quit mysql.
or 😎
mysqladmin -h hostname -u root password 'new password'
mysqladmin -h hostname flush-privileges
You might additionally need to insert a record with % or localhost as Host and root as user and fourteen 'Y' if you want to give root all rights.
INSERT INTO user ('localhost','root',PASSWORD('thepass'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
FLUSH PRIVILEGES;
(you can do that with mysqladmin either)
Then stop mysql (you might need to kill it manually). Start mysql as usual and try to connect
mysql -h localhost -u root -p
and enter the new root password when asked for it.