How to manage user account in mariadb


login into mariadb cli
mariadb > CREATE USER syaifful@localhost IDENTIFIED BY 'password';

syaifful is my username.
next, we can display the info.

mariadb > SELECT host,user,password FROM user WHERE user = 'syaifful';

now you can login into mariadb using your account.

Server > mysql -u syaifful -p

How to grant priviledge in mariadb

mariadb > GRANT SELECT, UPDATE, DELETE, INSERT on <table name> to syaifful@localhost;

now i will have access to the table.

To remove grant, we can use REVOKE command

mariadb > REVOKE ALL on <table name> to syaifful@localhost;

after any grant or revoke in the db, you need to reload the configuration to take place.

mariadb > FLUSH PRIVILEGES;

to display the grant

mariadb > SHOW GRANT FOR syaifful@localhost;

Comments