Connect to mysql server without sudo

后端 未结 9 1201
暖寄归人
暖寄归人 2020-12-02 08:39

The command:

mysql -u root -p

gives the error:

ERROR 1698 (28000): Access denied for user \'root\'@\'localhost\'
         


        
9条回答
  •  醉酒成梦
    2020-12-02 09:08

    Only the root user needs sudo requirement to login to mysql. I resolved this by creating a new user and granting access to the required databases:

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
    
    GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';
    

    now newuser can login without sudo requirement:

    mysql -u newuser -p
    

提交回复
热议问题