UBUNTU 22.04.1, mysql ver 8.0.30


I get sudo apt install mysql-server then

sudo mysql_secure_installation

Get in loop this error for each complicated passwords I tried: (contained: '<>&(*Pp1') returns↓

Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.


Then try:

  • sudo mysql
  • alter user 'root'@'localhost' identified with mysql_native_password by 'password';


Now ever returns:

error access denied for user 'root'@'localhost' (using password: YES) error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)


Then try

  • sudo apt-get remove --purge mysql*
  • sudo apt-get purge mysql*
  • sudo apt-get autoremove
  • sudo apt-get autoclean
  • sudo apt-get remove dbconfig-mysql
  • sudo apt-get dist-upgrade
  • sudo apt-get install mysql-server


Now ever shows:

ERROR 1045 (28000)


access denied for user 'root'@'localhost'

I can not refresh mysql with reinstall.

How can I retrieve the mysql and start step (1) newly cleaned from pre password configurations?

1 Answer 1


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

  1. sudo dpkg-reconfigure mysql-server-8.0

( use sudo dpkg --get-selections | grep sql to get your version)

completely remove MySQLconfig and data?

  1. sudo rm -r /var/lib/mysql

(Users and passwords (including the root password) are stored in the database itself, and the default data dir is /var/lib/mysql.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.