0

I get this error "access denied for user 'root'@'localhost' (using password no)" to which i've found a temporary solution to. I do in the terminal:

  1. sudo service mysql stop (Enter my password)
  2. (Then I navigate to usr/bin) and type: sudo mysqld_safe --skip-grant-tables
  3. (Open a new Terminal and type): mysql use mysql; UPDATE user SET password=PASSWORD('I_enter_my_new)password') WHERE user= 'root'; exit sudo service mysql start (then I enter my password)

This works fine only until I shut down my pc and log back in again . I would like a permanent solution to this please if anyone has one.

1615903
  • 32,635
  • 12
  • 70
  • 99

3 Answers3

1

Try doing all the --skip-grant-tables jazz, hop into mysql and do that:

grant all privileges on *.* to 'root' identified by 'newpassword' with grant option;
flush privileges;
quit;

Then you can restart the service and try logging in with mysql -uroot -p and enter the new password.

Hope that helps

jfornoff
  • 1,368
  • 9
  • 15
0

As mentioned at

https://stackoverflow.com/a/8789560/631619

The root user password is an empty string by default.

And (using password: NO) says that there is no password.

Did you try $ mysql -uroot ?

Also, I'm not sure if you should be stop and starting with sudo.

halfer
  • 19,824
  • 17
  • 99
  • 186
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
0

One thing: a command like

grant all privileges on *.* to 'root' identified by 'newpassword' with grant option;

will remain in the history, who knows for how long. Be careful in production, do not put 'newpassword' in cleartext but in the hashed form, or disable history:

export MYSQL_HISTFILE=/dev/null && mysql -u root

sc0p
  • 416
  • 2
  • 2