SELECT – gives the user permission to use the select command to fetch data from tables.USAGE – gives the user permission to log in to the MySQL server(given by default when creating a new user).In this section, we will explore other keywords that will allow us to set various types of permissions on the user. In the section above we saw how to grant read permissions to the user by using the keyword SELECT. In order for our new set permissions to take effect we need to reload all the privileges: FLUSH PRIVILEGES Step 3: Granting users other types of permissions in MySQL FROM The asterisks that we use for the database and table positions in the query above are wildcards and match any database or table depending on position. TO can also instruct MySQL to take away a certain permission from a user in the same format as above by only replacing the keyword GRANT with REVOKE and the keyword TO with FROM: REVOKE ON. Granting permissions is typically done in this format: GRANT ON. GRANT SELECT tells MySQL that the user will have nothing other than permissions to read data from a given database or databases. We do that by typing in the following command: GRANT SELECT ON *.* TO executing the query above we instruct MySQL to give our new user permission to use the command SELECT to read from databases on our MySQL server, we used the SELECT keyword in order to do that. Let’s say we want to provide our new user with permissions so that they can read data from all databases on our MySQL server. As an example: CREATE USER IDENTIFIED BY 'password' You can generate one from the command line.Īnother interesting thing to note about this command is that the hostname of the new user we just created can be a different hostname or IP address if we want the user to log in remotely. Pro-tip: always use a strong password for all your accounts. Step 2: Create MySQL UserĬreate a new MySQL user with the following query: CREATE USER IDENTIFIED BY 'password' If you haven’t installed MySQL on your server, you can check our tutorial on how to install MySQL on Ubuntu 16.04. To log in to our MySQL system we use the following command: # mysql -u root -pīy executing this command we tell the MySQL client to log us in with the root user and to prompt us for the user’s password. Step 3: Granting users other types of permissions in MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |