1sudo mysql
2
3ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
4
1UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';
2FLUSH PRIVILEGES;
3
1## ADD user in mysql && have problem with root user ##
2
3# First Login mysql shell..
4sudo mysql -u root -p
5
6## Also check if you are unable to login in mysql without sudo...
7
8## Creating new user and giving permissions...
9# Goto login shell of mysql... and type below commands...
10
11#1 show databases;
12#2 use mysql;
13#3 select user, host, plugin from mysql.user;
14#4 create user 'your_user_name'@'localhost' identified by 'password';
15#5 grant all privileges on *.* to 'your_user_name'@'localhost';
16#6 update user set plugin="caching_sha2_password" where User="your_user_name";
17 # .... Here caching_sha2_password you can see yours in #3 check
18 # your table and see column (plugin) don't use root plugin...
19#7 flush privileges;
20#8 EXIT
21
22#### DONE Now you created your user also you can user without sudo...
23
24mysql -u your_user_name -p
25## For password check your step #4 and enter same password...
26
27## Enjoy ALL DONE....
28## HAVE A NICE DAY!