I was changing the password of mysql to be able to connect a project that I have in Java, and it worked correctly for me. I used this to change mysql password.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
And in fact, the project that I have in Java works well for me.
The problem that I have at the moment is the following: I open the terminal, login as root user and write, mysql
but it shows me the following error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
I tried the following instructions:
- mysql
- mysql -u root
- mysqladmin -u root password [mypassword]
But the problem persists, Greetings!
What I did was simple.
Because I had changed the password and could not connect, I tried to find a way to enter mysql including the username and password, or at least be able to request the password, with the following instruction it worked:
After this, it will ask for your mysql password and that's it.
Note: If you try this command it will not work.
I think your problem is related to the existence of the my.cnf file in the root home if it is the user with which you are logged into the system and that in this file in the [client] section is the root user and the previous password as well as the socket to the database.