Examine Data in System Tables
Now that we've seen the system tables, let's examine the data in one of them. The user
table in the mysql
database contains information about MySQL user accounts.
Run the following command to see the structure of the user
table:
DESCRIBE user;
This will show you all the columns in the user
table. You'll see a lot of columns, as this table contains detailed information about each MySQL user.
Now, let's look at some of the data in this table. We'll focus on a few key columns:
SELECT User, Host, Account_locked, Password_expired FROM user;
This query selects four important columns from the user
table:
User
: The username of the MySQL account
Host
: The host from which this user is allowed to connect
Password_expired
: Whether the password has expired
You should see output similar to this:
+-------------+-----------+------------------+
| User | Host | password_expired |
+-------------+-----------+------------------+
| mariadb.sys | localhost | Y |
| root | localhost | N |
| mysql | localhost | N |
+-------------+-----------+------------------+
3 rows in set (0.001 sec)
This output shows us the MySQL user accounts that exist on the system. The root
user is the main administrative account, while the others are system accounts used by MySQL for various purposes.
To exit the MySQL shell, type:
EXIT;
This will return you to your regular terminal prompt.