How do I manage user privileges

Managing user privileges in MySQL is essential for maintaining security and ensuring that users can only access data that they are permitted to. This includes granting and revoking permissions for various database operations.

To manage user privileges, you can use the following SQL commands:

-- Granting privileges GRANT SELECT, INSERT ON database_name.* TO 'username'@'host'; -- Revoking privileges REVOKE INSERT ON database_name.* FROM 'username'@'host'; -- Viewing privileges SHOW GRANTS FOR 'username'@'host';

In this example:

  • GRANT command is used to assign specific privileges.
  • REVOKE command is used to remove specific privileges.
  • SHOW GRANTS command is used to display the current privileges of a user.

Keywords: MySQL user privileges manage user access SQL grant revoke database security