SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

前端 未结 10 536
灰色年华
灰色年华 2020-12-04 12:49

I just installed Ubuntu 16.04 and installed web server on it. Everything works well, but I cannot access database. Even if I create new user and grant all privileges, I can\

相关标签:
10条回答
  • 2020-12-04 13:39

    MySQL makes a difference between "localhost" and "127.0.0.1".

    It might be possible that 'root'@'localhost' is not allowed because there is an entry in the user table that will only allow root login from 127.0.0.1.

    This could also explain why some application on your server can connect to the database and some not because there are different ways of connecting to the database. And you currently do not allow it through "localhost".

    0 讨论(0)
  • 2020-12-04 13:44

    In short, on MariaDB

    1) sudo mysql -u root;
    2) use mysql;
    3) UPDATE mysql.user SET plugin = 'mysql_native_password', 
          Password = PASSWORD('pass1234') WHERE User = 'root';
    4) FLUSH PRIVILEGES;
    5) exit;
    
    0 讨论(0)
  • 2020-12-04 13:49

    With mysql Ver 14.14 Distrib 5.7.22 the update statement is now:

    update user set authentication_string=password('1111') where user='root';
    
    0 讨论(0)
  • 2020-12-04 13:53

    Users for mysql and for server are 2 different things, look how to add user to database and login with these credentials

    0 讨论(0)
提交回复
热议问题