1CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
2GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';
3FLUSH PRIVILEGES;
1CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
2#grant permissions to a specic database and/or table
3GRANT ALL PRIVILEGES ON database.table TO 'newuser'@'localhost';
4#Or grant wildcar permission to any DB/table
5GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
1CREATE USER 'pdam'@'localhost' IDENTIFIED BY 'pdamP@ssw0rd'; # create user
2GRANT ALL PRIVILEGES ON `pdam_db`.* TO 'pdam'@'localhost'; # set db access
3FLUSH PRIVILEGES; # Reload
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!