As expected, MySQL complains that you don’t have privileges to retrieve values from the columns other than track_id and time note that MySQL stops on its first error and doesn’t report all the columns you can’t access. If you now try to retrieve values
for columns you can access, it works as expected:
mysql>
SELECT time FROM TRACK LIMIT 3;+------+
| time |
+------+
| 8.10 |
| 5.27 |
| 8.66 |
+------+
3 rows inset sec)
Notice that, unlike databases and tables, you can seethe details of all columns in a table even if you don’t have access to them:
mysql>
DESCRIBE track;+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| track_id | int) | | PRI | 0 | |
| track_name | char) | YES | | NULL | |
| artist_id | int) | | PRI | 0 | |
| album_id | int) | | PRI | 0 | |
| time | decimal) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
5
rows inset secPrivilegesSo far, we’ve shown you how to add new users and grant privileges for databases, tables,
and columns.
In this section, we discuss the privileges in more detail and explain which ones are used at the global,
database, table, and column level. Then we discuss how the different privilege levels interact.
You can see a list of all available privileges by running the SHOW PRIVILEGES
command in the MySQL monitor Table 9-1 lists some of the more important of these.
Each row shows a privilege, followed by a description, and then a list of the four levels at which the privilege can be granted. For example,
the second row shows the ALTER
privilege that controls whether the ALTER TABLE
statement can be used, and shows that it can
be controlled at the global, database, and table levels:
Global levelYou can use ON in a
GRANT
statement to grant a user a particular privilege across all databases on the server.
Database levelYou can use, for example, music.*
to grant a privilege for one or more databases.
Share with your friends: