My local MySQL has no password for root user. I have added a new user with password and I’m trying to login to MySQL. This is what I got!
G:\XAMPP\mysql\bin>mysql -ugaja -p
Enter password: ****************
ERROR 1045 (28000): Access denied for user ‘gaja’@’localhost’ (using password: YES)

What I have done?
- Stop Mysql from XAMPP console
- Start the mysql from command line as given below
g:\xampp\mysql\bin\mysqld.exe --skip-grant-tables
- From another cmd I logged in to Mysql
mysql -u root
- Set the password string for root user
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';FLUSH PRIVILEGES;
- Check if passwordless login is allowed still.
G:\XAMPP\mysql\bin>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- Lets login with password now
G:\XAMPP\mysql\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.21 MySQL Community Server (GPL)
- Remove the anonymous user account
DROP USER ''@'localhost';
- Let me try to login with the user I’ve created newly
G:\XAMPP\mysql\bin>mysql -u gaja -p
Enter password: ****************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 MySQL Community Server (GPL)
Enjoy!