Is there a way to know your current username in MySQL?

MySQLMySQLi Database

Yes, you can use the method CURRENT_USER() to know the current username in MySQL.

The above method returns the username that can be used to authenticate the client connection.

The query is as follows −

mysql> select CURRENT_USER();

The following is the output −

+----------------+
| CURRENT_USER() |
+----------------+
| root@%         |
+----------------+
1 row in set (0.00 sec)

Or you can use USER() method from MySQL. The query is as follows −

mysql> select user();

Here is the output −

+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
raja
Published on 24-Dec-2018 11:13:48
Advertisements