Logo

dev-resources.site

for different kinds of informations.

Fix MySQL Cant Logged As Normal User

Published at
6/16/2020
Categories
linux
mysql
troubleshoot
Author
bramaudi
Categories
3 categories in total
linux
open
mysql
open
troubleshoot
open
Author
8 person written this
bramaudi
open
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.

Featured ones: