Default user for MySQL [duplicate]
With a fresh (but old) install of Ubuntu and MySQL, I found I could access the MySQL via command line client without being asked for any user or password.
Logging in as root requires the root password. But logging in without specifying the user (ie, just typing mysql
on the command line) asks me for neither user nor password.
I'm logged in as stewart@localhost
. No such user exists in the mysql.user
table.
This user can see the information_schema
database.
Why does the user exist? I thought MySQL users were separate from OS system accounts.
MySQL treats unknown username as anonymous user, so check for any lines in user-table that have empty string in the username column. Removing these, or setting the password, will prevent logging in without password.
You can check if you are connected as anonymous user with SELECT CURRENT_USER().