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

前端 未结 10 579
灰色年华
灰色年华 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:30

    If you are receiving that error even after creating a new user and assigning them the database previledges, then the one last thing to look at is to check if the users have been assigned the preiveledges in the database.

    To do this log into to your mysql(This is presumably its the application that has restricted access to the database but you as a root can be ablr to access your database table via mysql -u user -p)

    commands to apply

    mysql -u root -p 
    

    password: (provide your database credentials)

    on successful login

    type

    use mysql;
    

    from this point check each users priveledges if it is enabled from the db table as follows

    select User,Grant_priv,Host from db;
    

    if the values of the Grant_priv col for the created user is N update that value to Y with the following command

    UPDATE db SET Grant_priv = "Y" WHERE User= "your user";
    

    with that now try accessing the app and making a transaction with the database.

提交回复
热议问题