#in SQL execute
#GRANT type_of_permission ON database_name.table_name TO 'username'@'localhost';
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';
#reload all the privileges
FLUSH PRIVILEGES;
#Show Privileges
SHOW GRANTS FOR 'username'@'localhost';
#Revoke Privileges
REVOKE type_of_permission ON database_name.table_name FROM 'username'@'localhost';
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
SELECT * FROM mysql.user;
SELECT * FROM information_schema.user_privileges;
SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user;
SHOW GRANTS FOR 'my_user'@'localhost';
/*
The GRANT statement is used to assign full control over specific database by providing all priviledge.
Follow below statement for assign priviledge to user
*/
Syntax:
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' WITH GRANT OPTION;
/*
I hope it will help you.
Namaste
*/
/*
The GRANT statement is used to assign full control over specific database by providing all priviledge.
Follow below statement for assign priviledge to user
*/
Syntax:
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
-- create user if not exists
-- CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';");
-- grant all user permissions on all database and tables
-- GRANT ALL ON *.* TO 'username'@'localhost'");
-- create specific database
-- CREATE DATABASE newdatabase
-- grant all user permissions on db 'newdatabase' and all tables
-- GRANT ALL ON newdatabase.* TO 'username'@'localhost'");
-- grant all user permissions on db 'newdatabase' and table 'newtable'
-- GRANT ALL ON newdatabase.newtable TO 'username'@'localhost'");
-- to grant all privileges on 1 database and all its table
GRANT ALL PRIVILEGES ON database_name.* TO 'user'@'localhost';
-- to grant all privileges on all databases and all their respective tables
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';