i try to check my databases with :
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | db1 | | db2 | | sys | +--------------------+ 6 rows in set (0,09 sec)
I also try to check my databases on :
mysql> SELECT Db FROM mysql.db; +--------------------+ | Db | +--------------------+ | performance_schema | | sys | | db1 | | db2 | | db1 | | db2 | +--------------------+ 6 rows in set (0,00 sec)
Why are the results different with SHOW DATABASES;
and SELECT Db FROM mysql.db;
?
Can i update my databases on mysql.db
tables ??
Thanks in advance.
Advertisement
Answer
mysql.db id an internal system table, hence it is hard to find official documentation related to it. I found this MariaDB documentation, that states :
mysql.db is a system table that contains information about database-level privileges
This table is about storing user’s GRANTS
(which explains why you see the same db more than once).
Obviously it is not the good place to lookup available databases.
For that, it’s best to use SHOW DATABASES
or the information schema.