Let me make an educated guess as to what is happening:
When MySQL is first installed, the passwords for the 'root' and 'anonymous' users are blank by default. When you attempt to connect to the server and do not specify a username, you are logged in as the anonymous user, and the anonymous user cannot see any database but the 'test' database. This would explain why you cannot see the 'mysql' database in the results of a SHOW DATABASES statement.
My first piece of advice is to secure your default user accounts. I personally recommend removing the anonymous account completely and assigning a password for the root account.
shell> mysql -u root mysql mysql> DELETE FROM user WHERE User = ''; mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') -> WHERE User = 'root'; mysql> FLUSH PRIVILEGES;These steps will remove the anonymous account and set the password for the root user. First we login as the 'root' user and specify that we will be using the 'mysql' database (note the -u root clause), we then issue a DELETE statement that will remove the anonymous account (which has a blank username). Next we issue an UPDATE statement to set the password for the 'root' user and finally issue a FLUSH PRIVILEGES statement. The changes you make are stored immediately into the 'user' privileges table, but do not take effect on the server until the server re-reads the privileges table, thus the FLUSH PRIVILEGES statement is used to instruct the server to re-read the privileges table.
After this you can connect to the MySQL server as follows:
shell> mysql -u root -pThe client will prompt you for the root password after which you will be successfully connected as the root user. After connected as the root user you should be able to see the 'mysql' database when you issue a SHOW DATABASES statement.
Dig deeper on Introduction to Linux system administration
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.