I've tried multiple solutions from StackOverflow but haven't had any success. I'm on Mac OSX (Sierra 10.12.3) trying to create a new database and user. From terminal I enter:
mysql -u root
which outputs this error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
To try and resolve it I stopped mysql from 'System Preferences', then from terminal typed:
sudo mysqld_safe —skip-grant-tables
I opened a second tab and entered:
mysql -u root
Then from in mysql:
update mysql.user set password_expired = 'N', authentication_string=PASSWORD('newpassword') where user = 'root';
flush privileges;
I then restart the computer (killing the process with CMD + C doesn't work). After restarting, trying mysql -u root
still produces the same error.
I am able to access mysql via a MySQL client and a non-root user.
Any help is appreciated.
And mysql will ask for the password
Comment by @Niagaradad helped me. I was entering the wrong password the whole time.
Notice the error message
It says, Password: Yes. That means I am sending the password to SQL and that is wrong.
Usually root account doesn't have password if you haven't set one. If you have installed mysql via homebrew then root account won't have a password.
Here is the comment.
If you need to skip the password prompt for some reason, you can input the password in the command (Dangerous)
So Basically Just make sure that the Plugin Column contains "mysql_native_password".
Not my work but I read comments and noticed that this was stated as the answer but was not posted as a possible answer yet.
Try this (on Windows, i don't know how in others), if you have changed password a now don't work.
1) kill mysql 2) back up /mysql/data folder 3) go to folder /mysql/backup 4) copy files from /mysql/backup/mysql folder to /mysql/data/mysql (rewrite) 5) run mysql
In my XAMPP on Win7 it works.
For security reason mysql -u root wont work untill you pass -p in command so try with below way