DEV Community

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

Posted on

1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay