

MySQL provides us with the function user() that can be used to retrieve the database’s current user. Most of the columns of the user table that store the values like boolean, i.e., either true or false, have the datatype of an enum having values ‘Y’ that stands for true and ‘N’ that specifies false, i.e., enum(‘N’,’ Y’) datatype that informs whether the particular privilege is assigned to the user or not.

Then, in that case, you can choose privilege-related columns as done in the following SELECT query:Įxplanation: Other columns can be retrieved, whichever you want, using the select query. Step 4: Suppose you want to retrieve assigned privilege-related information of the users. To retrieve more information about users, we can add the columns we want to retrieve in the select query as follows: Step 3: To retrieve the data from the user table of the MySQL database, you first need to login to MySQL using MySQL -u root pg command if you are using MySQL from the command line through the terminal or if you are using an IDE, enter your credentials or editor such as sqlyog of workbench.Īn alternative to using the above select query, you can first fire the command to select the MySQL database and then fire the following choose query that will produce the same output as above: Step 2: We will first retrieve the names of all the users from the user table using the following SELECT query:Įxplanation: We can see that four users are present for my database server. If you are currently using MySQL as your chosen database, you can utilize the following method:
