Example for MySQL Grant

Consider a an account is created using GRANT command to provide privileges to other users. The following MySQL codes are used to create account and grant permission to other users.

CREATE USER ‘Trinity@host’ IDENTIFIED BY ‘Pass1’;

GRANT ALL ON *.* TO ‘Trinity@host’ WITH GRANT OPTION;

The clause ON *.* will provide access to all tables and objects present in the database. Only “host” database server will be allowed to connect the user “Trinity”, this process will secure MySQL server.

The following SQL query is used to create a user who can access a sample database and connect with any host.