Monday, December 27, 2021

create/drop/Alter user in MySQL database?

 The following is the basic syntax to create a new user in MySQL:


CREATE USER testmysqlusr IDENTIFIED BY 'petcom123';  

***********************************************************



mysql> CREATE USER testmysqlusr IDENTIFIED BY 'petcom123';

--------------

CREATE USER testmysqlusr IDENTIFIED BY 'petcom123'

--------------


Query OK, 0 rows affected (0.04 sec)




ALTER USER 'testmysqlusr'@'localhost' IDENTIFIED BY 'macd123'; 



Query OK, 0 rows affected (0.04 sec)


mysql>SHOW GRANTS FOR 'testmysqlusr'@'localhost';



mysql> SHOW GRANTS FOR 'testmysqlusr'@'localhost';

--------------

SHOW GRANTS FOR 'testmysqlusr'@'localhost'

--------------


ERROR 1141 (42000): There is no such grant defined for user 'testmysqlusr' on host 'localhost'

mysql>


mysql> drop user testmysqlusr;

--------------

drop user testmysqlusr

--------------


Query OK, 0 rows affected (0.01 sec)



No comments:

Post a Comment