DEV Community

Cover image for Fix MySQL Cant Logged As Normal User
Brama Udi
Brama Udi

Posted on

Fix MySQL Cant Logged As Normal User

Problem: User "root" can't logged in normal terminal, but can login on super user terminal only a.k.a sudo.

Solution:

1.) Login as sudo.

sudo mysql -u root
Enter fullscreen mode Exit fullscreen mode

2.) Check if root user is exists (actually this is optional).

SELECT User,Host FROM mysql.user;
Enter fullscreen mode Exit fullscreen mode

3.) Delete root user in MySQL.

DROP USER 'root'@'localhost';
Enter fullscreen mode Exit fullscreen mode

4.) Create the root user again.

CREATE USER 'root'@'%' IDENTIFIED BY '';
Enter fullscreen mode Exit fullscreen mode

5.) Setup permission for the new user.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
Enter fullscreen mode Exit fullscreen mode
FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

Logout from MySQL (quit) then try login back with normal terminal user, it should be fixed.

Top comments (0)