mySQL comes with a pretty powerful security system, the grant tables, which allows database administrators to precisely control access to databases, tables and even specific rows and columns. In this article, find out how the five grant tables combine to offer power users a tremedous amounts of flexibility and control over database access and operations.
Modifying the mySQL grant tables requires superuser access to the mySQL database server. So the first order of business is to ensure that you have this level of access, and can alter table records
If you've installed the server yourself, on your own development machine, you would have been told to enter a root password at the time of installation. Hopefully, you did this - too many people leave the password blank, thereby opening up a gaping security hole - and still remember the password you used.
To verify that you have the required access, log into the server as the "root" user
$ mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.22.32
Type 'help;' or '\h' for help. Type '\c' to clear the buffer
mysql>
and ensure that you can view the contents of the tables
in the "mysql" database - this is the database that contains all the grant tables.
mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SHOW TABLES;
+-----------------+
| Tables in mysql |
+-----------------+
| columns_priv |
| db |
| host |
| tables_priv |
| user |
+-----------------+
5 rows in set (0.00 sec)
Of course, root-level access is typically available only
to the system administrator - other users have a lower security rating and, consequently, limited access. Each of these "ordinary" users will typically connect to the database by supplying his or her own user name and password - like this:
$ mysql -h localhost -u joe -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 3.22.32
Type 'help;' or '\h' for help. Type '\c' to clear the buffer
mysql>
The purpose of the mySQL grant tables is to make it
possible to manipulate security settings for these "ordinary" users, and customize each user's level of access to a very fine degree.