EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB show users
Secondary Sidebar
MariaDB Tutorial
  • MariaDB
    • MariaDB Versions
    • MariaDB? list users
    • MariaDB Commands
    • MariaDB odbc
    • MariaDB Workbench
    • MariaDB for windows
    • MariaDB Server
    • MariaDB? Data Types
    • MariaDB? boolean
    • MariaDB phpMyAdmin
    • MariaDB Mysqldump
    • MariaDB Java Connector
    • MariaDB insert
    • MariaDB UPDATE
    • MariaDB? rename column
    • MariaDB AUTO_INCREMENT
    • MariaDB Timezone
    • MariaDB GROUP_CONCAT
    • MariaDB wait_timeout
    • MariaDB MaxScale
    • MariaDB? with
    • MariaDB GUI
    • MariaDB? create?table
    • MariaDB? SHOW TABLES
    • MariaDB alter table
    • MariaDB List Tables
    • MariaDB JSON Functions
    • MariaDB Foreign Key
    • MariaDB? trigger
    • MariaDB Grant All Privileges
    • MariaDB Select Database
    • MariaDB? create database
    • MariaDB Delete Database
    • MariaDB Join
    • MariaDB JSON
    • MariaDB? show databases
    • MariaDB List Databases
    • MariaDB Functions
    • MariaDB? TIMESTAMP
    • MariaDB create user
    • MariaDB add user
    • MariaDB Max Connections
    • MariaDB show users
    • MariaDB Delete User
    • MariaDB? change user password
    • MariaDB? change root password
    • MariaDB reset root password
    • MariaDB IF
    • MariaDB bind-address
    • MariaDB Transaction
    • MariaDB Cluster
    • MariaDB Logs
    • MariaDB Encryption
    • MariaDB? backup
    • MariaDB Replication
    • MariaDB max_allowed_packet
    • MariaDB? performance tuning
    • MariaDB export database
    • MariaDB? import SQL

MariaDB show users

MariaDB show users

Introduction to MariaDB show users

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

Syntax

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

For 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 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 running this MySQL query:

SELECT * FROM mysql.user;

It should be noted that the above query will return and show the entire columns present in the mysql.user table that creates for a lot of result output. Thus, for the practical purpose it may be trimmed down few fields for displaying somewhat like this one below:

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 as:
  • $ 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 provided below to display the user accounts either 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 previous one where it is allowed to logging for showing users together with their respective host name 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 result in generating 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 as: 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 MariaDB, the server provisions information about the account users present in the database table which is defined as user available in the mysql database. Therefore, to fetch the names of all user accounts in MariaDB by applying the SELECT keyword statement that will retrieve all table rows from this mysql.user table in the server, which is typed as:

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

Now, as you can see that from the mysql.user server table the above command has retrieved just two table columns i.e. user and host, but more than 40 table columns are still available or contained by the mysql.user table such as password, update_priv, insert_priv, trigger_priv, select_priv, etc.

Generally, a user account in the MariaDB or MySQL server holds two sections where first is username and the second on is the hostname. A user can implement the command as DESC mysql.user; type statement to view the info about the database table columns. So, once the table column is known a user can execute the query against any specific data of the table.

For an 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 but associated to databases as the succeeding 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 those who have access to the level of databases privilege saved in the table defined as mysql.db will be viewed. Hence, with this 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 in the server.

Also, you can yield 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 entire table columns present in the table mysql.user but this makes the process of providing output a long execution thus, there may be need for trimming down 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 available in the mysql.user table:

DESC mysql.user;

Output:

output 6

Conclusion

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

Recommended Articles

This is a guide to MariaDB show users. Here we discuss How to show users in MariaDB using various ways along with the examples. You may also have a look at the following articles to learn more –

  1. MariaDB Timezone
  2. MariaDB Commands
  3. MariaDB Foreign Key
  4. MariaDB MaxScale
Popular Course in this category
SQL Training Program (10 Courses, 8+ Projects)
  10 Online Courses |  8 Hands-on Projects |  80+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*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?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more