0

I install on Ubuntu LAMP with MYSQL. I try login to mysql by command mysql but there is an

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

. I try use

Blockquote

sudo mysql_secure_installation

but it's the same error

darek_82
  • 361
  • 1
  • 3
  • 13
  • So did you enter a password for `root` when you ran `mysql_secure_installation` – RiggsFolly Feb 23 '23 at 18:34
  • Show (without the password) the full command line you used with `sudo mysql_secure_installation` – RiggsFolly Feb 23 '23 at 18:36
  • First I enter on user account sudo mysql_secure_installation and I had line Securing the Mysql server deployed and next line enter password for user root, sow I enter root password and than I have Error 1045: Access denied for user 'root'@'localhost' (using password: YES) – darek_82 Feb 23 '23 at 18:58
  • Does this answer your question? [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – Tangentially Perpendicular Feb 23 '23 at 19:20
  • I don't understand it. How I should delete anonymous user if I can't login to MYSQL?? – darek_82 Feb 23 '23 at 19:42

2 Answers2

0

Follow this step

  • Change the password of root by mysql prompt

    mysql -u root -p

  1. update password

    UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root';

  2. Edited line in the file config.inc.php with the new root password:

    $cfg['Servers'][$i]['password'] = 'MyNewPass'

Pankti Shah
  • 141
  • 8
  • 1 point I have Error 1045: Access denied for user 'root'@'localhost' (using password: YES) – darek_82 Feb 23 '23 at 20:49
  • 1
    Use [SET PASSWORD](https://dev.mysql.com/doc/refman/8.0/en/set-password.html) to set the password rather than ugly old hacks like `UPDATE mysql.user` as it has further consequences, isn't portable, and in the form in this answer, it isn't complete. Ref [other answer](https://stackoverflow.com/questions/64841185/error-1356-hy000-view-mysql-user-references-invalid-tables-or-columns-o/64841540#64841540), – danblack Feb 24 '23 at 03:14
0

When you are trying to access the database connection you need to give the password aswell. which you must have set during installation.

If you don't remember it you will have to reset the password.

JustaNobody
  • 150
  • 8