Michael Michael - 6 months ago 8
SQL Question

Can't login to mysql with new password

I am new to MySQL.

I've created a new user:

CREATE USER 'geo'@'localhost' IDENTIFIED BY '12345';
GRANT ALL PRIVILEGES ON *.* TO 'geo'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;


When I open MySQL console window and type in password that I've set window gets closed.

My question is: Why I can not login to MySQL with new password? What do I miss?

Answer

Enter to mysql as root and do following:

USE mysql;
DELETE FROM user WHERE User='geo';
GRANT ALL ON *.* TO 'geo'@'localhost' IDENTIFIED BY '12345';
GRANT ALL ON *.* TO 'geo'@'127.0.0.1' IDENTIFIED BY '12345';
FLUSH PRIVILEGES;

Or You can create user that is accessible from any IP (if mysql bind=0.0.0.0 in config, otherwise it will listen local connections):

USE mysql;
DELETE FROM user WHERE User='geo';
GRANT ALL ON *.* TO 'geo'@'%' IDENTIFIED BY '12345';
FLUSH PRIVILEGES;

Your issue I think You do create 'geo'@'localhost', but some mysql clients use 127.0.0.1 and others localhost, so for mysql these are different hosts.