1

I have an interseting problem. I try to access my mysql server as root (also not wirking with debain-sys-maint) unsing

sudo mysql -u root -p

I reinstalled complete server (purged all).

sudo mysql_secure_installation

worked once after reinstall. and then

sudo mysql

worked. But after reset auth to native password I still get this error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

regardless what i am doing, there is no login to mysql possible. Any ideas to solve that?

k1ngarthur
  • 124
  • 1
  • 12
  • https://stackoverflow.com/questions/489119/mysql-error-1045-access-denied – Prashant Patel Nov 18 '19 at 13:06
  • 1
    tanks, already tried that. but i'll try again on new install. – k1ngarthur Nov 18 '19 at 14:15
  • still no success. after reinstall of mysql-server i was able to use sudo mysql using mysql_secure_installation. I added a root password with UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root'; and FLUSH PRIVILEGES;. I switched to password auth via ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; and FLUSH PRIVILEGES; but mysql -u root -p is still Access denied for user 'root'@'localhost' (using password: YES). mysqld_safe --skip-grant-tables is also the same. – k1ngarthur Nov 22 '19 at 14:41
  • /var/log/mysql/error.log: https://pastebin.com/EGF2FUsn – k1ngarthur Nov 22 '19 at 15:55
  • have you try without password ? –  Nov 24 '19 at 21:07
  • Yes. No change. – k1ngarthur Nov 25 '19 at 05:38
  • this is windows menthality to reinstall everything. Linux user never does this. You must start mysql in "single-user-mode", please google for it. –  Dec 10 '19 at 21:25

1 Answers1

1

first stop the service

service mysql stop


then start mysql in single user mode :

mysqld_safe –skip-grant-tables &

Then log in without any password

mysql

then change root'S password "new_pass"

UPDATE mysql.user SET password=password(‘new_pass’) WHERE User=’root’;

at the end :

FLUSH PRIVILEGES;
exit;

now you are on console again using mysqladmin log in using your new password and shutdown the singleusermode

mysqladmin -u root -p shutdown

Here shutdown is not the password it is the command, you will be prompted for the password.

then you start the mysql service normally

service mysql start
  • 1
    shutdown was not neccessary, bu helpful. restarting the service also worked for me. – k1ngarthur Sep 09 '20 at 11:20
  • 1
    @k1ngarthur but you must exit the singelusermode ? –  Sep 09 '20 at 15:03
  • Did not remember. I think not. Simply set the Auth type to basic with code above. Because on newer systems Auth for root is done with systems root account. – k1ngarthur Sep 10 '20 at 05:34