- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is there a way to know your current username in MySQL?
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)
Advertisements