Does a MySQL User needs to be added to MySQL “system”?
I am learning MySQL basics but this question just popped out. Here is why:
:~$ mysql -u johndoe
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT User();
+-------------------+
| User() |
+-------------------+
| johndoe@localhost |
+-------------------+
1 row in set (0.00 sec)
mysql> quit
Bye
of course I didn’t set up a user named johndoe, but it seems that I am able to enter mysql with any username. I’m not saying I’ll see any database at all, as it may not have been set any databases where johndoe, for example, could do something.
So my question finally is: Is this true or I am seen it the wrong way?
actually, MySQL connected you as an anonymous user (”@localhost) because the user “johndoe@localhost” does not exist. run “SELECT CURRENT_USER()” and you’l see what I mean, also, if you check the user table in the mysql database you’l find a row where host=’localhost’ and user=”.