1

With 10.4.6-MariaDB on my Mac OS 10.14.5 Logged in as root I can see the list of users on my server with

MariaDB [(none)]> select Host,User from mysql.user;
+--------------+-----------+
| Host         | User      |
+--------------+-----------+
| localhost    |           |
| localhost    |           |
| localhost    | root      |
| localhost    | user_Name |
| PCName.local |           |
+--------------+-----------+
5 rows in set (0.001 sec)

but when logged in as user_Name and I check the current user

MariaDB [(none)]> select user()
    -> ;
+-------------------------------+
| user()                        |
+-------------------------------+
| user_Name@localhost@localhost |
+-------------------------------+
1 row in set (0.000 sec)

That doesn't seem right to @localhost written twice.

So my question is why this happening?

2

What you should run is this

Please run this query:

SELECT USER(),CURRENT_USER();

What do these functions return ???

  • USER() reports how you attempted to authenticate in mysqld
  • CURRENT_USER() reports how you were allowed to authenticate by mysqld

Please note that CURRENT_USER() should return something from mysql.user. You said that USER() returns user_Name@localhost@localhost. If CURRENT_USER() comes back with the same response as USER(), then MariaDB has a bug.

Since USER() reports how you attempted to authenticate in mysqld, my guess would be that's probably how you typed it.

mysql -u user_Name@localhost

You should login to MariaDB like this

mysql -u user_Name -hlocalhost

Try it again and see. I discussed this before in this forum : MySQL error: Access denied for user 'a'@'localhost' (using password: YES)

3
  • Yes I logged in with the wrong login. Your second example needs a space after -h. thanks for explain user() and current_user()
    – OrigamiEye
    Jul 24 '19 at 15:37
  • @OrigamiEye it also works without the space mysql -uuser_Name -hlocalhost. Try it and see. Jul 24 '19 at 15:46
  • that's wild, it works.
    – OrigamiEye
    Jul 24 '19 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.