Resolve error "1045 (28000): Access denied for user username@localhost (using password: YES)"

Home > Search

When attempting to connect to MySQL or MariaDB, error 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES) appears. 

  1. In Tereminal, type mysql -u root;
  2. Update the password using one of the following commands
    • UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    • UPDATE mysql.user SET authentication_string=PASSWORD('password')  WHERE  User='root';


Follow these steps if you are unable to connect to MariaDB with commands such as mysql, mysql -u root, and mysql -u root -p.

  1. In Terminal, type /sbin/service mariadb stop
  2. Type mysqld_safe --skip-grant-tables &
  3. There will be a flashing cursor. Type mysql -u root
  4. Type use mysql;
  5. Type update user set password=PASSWORD("new-password") where User='root';
  6. Type exit
  7. Now try to log into MariaDB with the command mysql -u root -p;

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.