It seems that mysql daemon in xampp has different default value for the basedir than the my.ini setting file.
So when I've reseted the password without adding the same --defaults-file as XAMPP does when it runs mysqld - I actually reseted a password for a different "workspace".
Thanks to @andy, because his comments led me to the solution :)
So the right way to reset XAMPP's MySQL root user ( on Windows ) is:
1) Stop MySQL with XAMPP Control
2) Prepare init file
Create file called mysql-init.txt directly on C:\ drive and fill it with this content:
#INSERT INTO mysql.user (User,Password) VALUES('root',PASSWORD('root'));
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost';
FLUSH PRIVILEGES;
- # is a comment - if you did not have a root user or deleted it by accident - uncomment the first line and comment the second line
These commands create a MySQL user "root" with password "root" and give him/her ALL privileges on everything.
3) Run MySQL daemon with proper params
Run YOUR_XAMPP_INSTALL\mysql\bin\mysqld.exe with these params:
Note the double slashes "\\" instead of single slashes "\"
--defaults-file="c:\\YOUR_XAMPP_INSTALL\\mysql\\bin\\my.ini"
--init-file=C:\\mysql-init.txt
So the whole command for cmd.exe could look like:
c:\YOUR_XAMPP_INSTALL\mysql\bin\mysqld.exe --defaults-file="c:\\YOUR_XAMPP_INSTALL\\mysql\\bin\\my.ini" --init-file=C:\\mysql-init.txt
Of course replace YOUR_XAMPP_INSTALL with the path to your custom xampp install ( very often it is just "xampp" resp. "C:\xampp"). And of course if you are operating on a different drive than "C", change C:\ to WhatEverLetterYouWant:\
4) Try to login on http://localhost/phpmyadmin/
Try to login on http://localhost/phpmyadmin/ with user root and password root, if it does not work, you have done something wrong in the previous 3 steps
5) 4) went fine? => Stop MySQL with XAMPP Control
6) Start MySQL with XAMPP control
7) Try to login again with root/root
8) 7) went fine? => Done :)
References:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql