MYSQL User Account and Permission Queries

 C:\Program Files\MySQL\MySQL Workbench 8.0 CE>

mysql.exe -u*** -p*** -h***

select user,host from mysql.user;
show create user 'USER'@'HOST';
show grants for 'USER'@'HOST';
 
create user ... using syntax from the show create user ...
grant ... using syntax from show grants ...
 
flush privileges;


To Get Grants and Create Users for All Users in MySQL / SHOW GRANTS for EVERYONE!
... you'd need to do this and run the output:

SELECT
  CONCAT('CREATE USER IF NOT EXISTS ''',`user`,''' IDENTIFIED BY PASSWORD ''',`authentication_string`,''';') AS 'create',
  CONCAT('SHOW GRANTS FOR `',`user`,'`@`',`Host`,'`;') AS 'grants'
FROM `mysql`.`user`;

Easiest to collect the outputs if you're running MySQL command line

Comments