Pages

Tuesday, April 19, 2022

MySQL User Management

MySQL User Management 


-- List all users present in mysql

mysql> select user,host,account_locked,password_expired from mysql.user;


Create user in mysql:

mysql> create user 'mqmtest_user'@'%' identified by 'mqmtest_user';

mysql> GRANT ALL ON *.* TO 'mqmtest_user'@'localhost';


View already created users:

mysql> select host, user from mysql.user;


Drop user:

mysql> drop user 'mqmtest_user'@'localhost';


Rename a user:

mysql> rename user 'mqmtest_user3' to 'mqmtest_user007';


change password of a user:

mysql> ALTER USER 'dbaprod'@'%' IDENTIFIED BY 'dbaprod';


Change resource option:

mysql> alter user 'dbaprod'@'%' with MAX_USER_CONNECTIONS 10;


Lock/unlock an account:

mysql> alter user 'dbaprod'@'%' account lock;

mysql> alter user 'dbaprod'@'%' account unlock; 

No comments:

Post a Comment