EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB show users
 

MariaDB show users

Updated June 5, 2023

MariaDB show users

 

 

Introduction to MariaDB show users

MariaDB Show Users is a MariaDB command responsible for showing the list of users in a database server. The user tables save the user records, which include the usernames for login, passwords, user privileges, and other information. You will find a system table as MySQL. User in MariaDB as this is a split of MySQL, so this system table will still be available as mysql.user for the compatibility issue. Hence, running a query against MySQL. The user system table will return all of the Users created in the database MariaDB along with the information about these users.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax

For the MariaDB Show User command, which is used for retrieving all users available in MariaDB, we will execute the succeeding query statement as syntax:

SELECT User FROM mysql.user;

Let us discuss the details of mysql.user MariaDB table comprising the columns explained below:

  • Host: User host that can be localhost, %, etc.
  • User: Name of the user such as admin, root, or any specific one, etc.
  • Password: It denotes the hashed value as a password
  • Authentication_string: It denotes the security column.

Initially, to view the list of users in the MariaDB database, it is required to login into your admin account as an administrative level user through the mysql command-line client that runs this MySQL query:

SELECT * FROM mysql.user;

Please note that executing the above query will return and display all the columns present in the mysql.user table, resulting in a large output of results. You can trim down the fields to display specific information for practical purposes. Here’s an example of a trimmed-down query to fetch selected fields from the mysql.user table:

SELECT host, user, password FROM mysql.user;

How to show users in MariaDB using various ways?

  • In this MariaDB Show Users, initially, login to your MariaDB/MySQL server using the mysql client as the root user; we will type the following query:
  • $ mysql -u root –p, where p is for the password associated with this username, or also can type: $ mysql –u root –h localhost –p mysql. After the user admin has logged in, you can execute different SQL queries below to display the user accounts in MySQL or MariaDB database server.
  • For the next step, you need to script the command at mysql>prompt for viewing the list items of user accounts available in the MariaDB database using the SELECT keyword and table mysql.user in the server as: SELECT User FROM mysql.user;
  • After this, one can further use some commands similar to the previous one where it is allowed to logging for showing users together with their respective hostname or password: SELECT host, user, password FROM mysql.user; or, SELECT host, user FROM mysql.user;
  • Again, for any repetition of database user names, we can avoid it by using the SQL code written as SELECT User Distinct From mysql.user, where the keyword as SELECT User DISTINCT in the query statement will generate the unique values.
  • You can even yield the list of column fields associated and selected from the MariaDB mysql.user table through the SQL query command as follows: DESC mysql.user
  • To discover the user rights granted, we will implement the following command: SELECT User, Db, Host From mysql.db;
  • Next, one can even find the privileges provided to a distinct MySQL user as SHOW GRANTS for ‘username’@’localhost’;

Examples

In the “mysql” database, the MariaDB server provides information regarding the account users present in the “user” database table. To fetch the names of all user accounts in MariaDB, you can use the SELECT keyword statement to retrieve all table rows from the mysql.user table in the server. The query would be typed as follows:

SELECT User FROM mysql.user;

On execution, the output will be as follows:

Similarly, we can also fetch the host names associated with the users using the query command as,

Output:

MariaDB show users output 1

Again, run the query as:

SELECT User, Host FROM mysql.user;

Output:

MariaDB show users output 2

The above command has retrieved only two table columns, user and host, from the mysql.user server table. However, the mysql.user table still contains over 40 table columns, including password, update_priv, insert_priv, trigger_priv, select_priv, and others.

Generally, a user account in the MariaDB or MySQL server holds two sections where the first is the username, and the second one is the hostname. A user can implement the command as DESC mysql.user; Type statement to view the info about the database table columns. A user can execute a query to retrieve specific data from a table column once they know the column.

For instance, suppose we want to fetch the information of user accounts in MariaDB, including the password for its status as lively or expired; then we will implement the following query statement:

SELECT User, Host, password_expired, Password FROM mysql.user;

Output:

MariaDB show users output 3

For retrieving information about users associated with databases, the next query will display data about all databases and related users:

SELECT User, host, db FROM mysql.db;

Output:

output 4

Here, the information of users accessing the database privilege level is saved in the table defined as mysql.db will be viewed. Hence, we can discover the users who can manage a particular database with linked privileges. You can even use the WHERE clause to specify any database available on the server.

Also, you can yield a list of all users from the table mysql.user in MariaDB with the query as follows with administrative privilege:

SELECT * FROM mysql.user;

Output:

output 5

Perhaps, this command will show the entire table columns present in the table mysql.user, but this makes the process of providing output a long execution; thus, there may be a need for trimming down a few of the columns in practical implementation to view the users as required, which can be achieved with the previous command statement as:

SELECT User, Host FROM mysql.user;

Using the below query, you will fetch lists of table fields in the mysql.user table:

DESC mysql.user;

Output:

output 6

Conclusion

  • Hence, MariaDB Show Users is a MariaDB SQL command to draw the user accounts from table mysql.user or for the given MariaDB Database with associated privileges.
  • Using this MariaDB Show User query command, one can view the users in MariaDB and the permissions provided to each.

Recommended Articles

We hope that this EDUCBA information on “MariaDB show users” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. MariaDB Timezone
  2. MariaDB Commands
  3. What is MySQL?
  4. MariaDB MaxScale

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW