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';
// login to mysql as root
mysql -u root -p
// use mysql database
use mysql;
// list users
select user,host from user;
# List All Unique Usernames
SELECT DISTINCT User FROM mysql.user;
# List All Usernames + Hostnames;
SELECT User,Host FROM mysql.user;
-- 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';