I am installing a MySQL server (actually a Percona server, but it does not matter) and I am setting a password for the root user. At the end, I got the following:
mysql> select host, user, password from user; +-----------+------------------+-------------------------------------------+ | host | user | password | +-----------+------------------+-------------------------------------------+ | localhost | root | *huge string here, no kidding | | localhost | debian-sys-maint | *another huge string here | +-----------+------------------+-------------------------------------------+ 2 rows in set (0.00 sec)
I thought this should not allow the root user to connect without a password. However, if I go to the command line, I can connect to mysql -u root or just mysql . If I do mysql -u root -p and press enter for password, then I get ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).
Can someone explain to me how to make sure that the user can only connect to the password?
Edit: if necessary, I set the password using SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somethinghere');
Edit: the output of show grants , it indicates that I used a password to log in, but I did not.
mysql> show grants; +----------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@localhost | +----------------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*huge string here, no kidding' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +----------------------------------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
source share