How can permissions be granted to a user in MySQL?
In MySQL, you can use the GRANT statement to grant permissions to users. Here are some common examples of GRANT statements.
- Grant all permissions to the user.
- Give ‘username’@’localhost’ full access to the database named database_name.
- Grant users specific permissions.
- Provide ‘username’@’localhost’ with permission to select, insert, update, and delete data in database_name.table_name.
- Grant the user permissions to all databases.
- Give the user ‘username’ all privileges on all databases on the localhost.
- Granting users remote access permissions:
- Give full access to all privileges on the database named database_name to the user with the username ‘username’ from any location, using the password ‘password’.
- Refresh permission:
- Reload the privileges.
Before using the GRANT statement, make sure you have sufficient permissions to grant permissions to other users.