Database Reference
In-Depth Information
|
+---------------------------------------------------------------------------+
Now Lena can see only that one table in the birdwatchers database. Here is what hap-
pens if she executes the following from her home computer:
mysql --user lena_stankoska --password='her_password_123' --host
rookery.eu \
--execute="SHOW TABLES FROM birdwatchers;"
+------------------------+
| Tables_in_birdwatchers |
+------------------------+
| bird_sightings |
+------------------------+
To give her access to more tables in the birdwatchers database, we couldexecute a
GRANT statement for each table. That can be tedious with a database that has many tables,
to give her access to many of them but not all. But there's no simple way around it. I have
requested while writing this chapter that a feature be added to MariaDB to specify mul-
tiple tables in a single GRANT statement. So maybe one day there will be an easy way to
do it with MariaDB. For now, you can either manually enter the GRANT statement many
times, or you can create a short script to do it.
For example, suppose that we want to give Lena access to all of the tables in the bird-
watchers database, except ones with personal and sensitive information. The tables to
exclude would be the humans table and the two tables containing information about chil-
dren, the birder_families and birding_events_children tables. Here's how
such a shell script might look:
#!/bin/sh
mysql_connect = "mysql --user root -pmy_pwd"
results = `$mysql_connect --skip-column-names \
--execute 'SHOW TABLES FROM birdwatchers;'`
items = $ ( echo $ results | tr " " "\n" )
for item in $ items
do
if [ $ item = 'humans' ] ||
[ $ item = 'birder_families' ] ||
[ $ item = 'birding_events_children' ]
Search WWH ::




Custom Search