Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does linux query users of mysql

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how linux queries mysql users". In daily operation, I believe many people have doubts about how linux queries mysql users. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how linux queries mysql users". Next, please follow the editor to study!

The method of querying mysql users: 1, using the "mysql-u root-p" command to log on to the root users in the database; 2, using the "SELECT User, Host, Password FROM mysql.user" query statement to show all the users in the mysql.

The operating environment of this tutorial: linux7.3 system, mysql8.0.22 version, Dell G3 computer.

How does linux query mysql users?

1. Log into the database

First, you need to log in to the database using the following command. Note that you must be a root user.

# # mysql-u root-p

two。 Query user table

In fact, there is a built-in database called mysql in Mysql, which stores some data of Mysql, such as users, permissions information, stored procedures, etc., so we can display all users through the following simple query statement.

SELECT User, Host, Password FROM mysql.user

You will see a message like this:

+-+ | user | host | password | +-+ | root | | localhost | 37as%#8123fs | | debian-test-user | localhost | HmBEqPjC5Y | | johnsm | localhost | | brian | localhost | | root | 111.111.111.1 | | guest |% | | linuxprobe | 10.11.12.13 | RFsgY6aiVg | +-| -+ 7 rows in set (0.01 sec)

If you want to add or decrease the display of some columns, then you only need to edit the sql statement, for example, you only need to display the user's user name, then you can use the

SELECT User FROM mysql.user

Expand knowledge

Show all users (do not repeat)

Friends who are familiar with Mysql know the role of DISTINCT modification, by the way, it is to remove duplicate data, so we can use the following command to display all your Mysql users and ignore those users who are just different hostnames.

SELECT DISTINCT User FROM mysql.user

The output of this command looks like this:

+-+ | user | +-+ | root | | debian-test-user | | johnsm | | brian | | guest | | linuxprobe | +-+ 6 rows in set (0.01 sec) so far The study on "how to query mysql users by linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report