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

Basic Operation of Mysql based on linux operating system (3)

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Basic Operation of Mysql based on linux operating system (3)

Knowledge point 1: view all users in MYSQL database

Command: select distinct concat ('User:''',user,'''@''',host,''';') as query from mysql.user

Note: (1) the keyword DISTINCT is used to return a unique different value.

Syntax: SELECT DISTINCT column name FROM table name

(2) the SQL CONCAT function is used to concatenate two strings to form a single string.

Compare the usage of the two:

Knowledge point 2: view the permissions of a specific user in the database

(1) Command: show grants for 'cacti'@'127.0.0.1'

The screenshot is as follows:

(2) Command: select * from mysql.user where user='cacti'\ G

The screenshot is as follows:

Knowledge point 3: to view the user table structure, specific items can be queried in combination with the table structure.

Command: desc mysql.user

The screenshot is as follows:

Knowledge point 4: delete users

Command: delete from mysql.user where user='cacti'and host='127.0.0.1'\ G

The screenshot is as follows:

Note: mysql > flush privileges; (refresh database)

Mysql > drop database testDB; / / Delete the user's database

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

Database

Wechat

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

12
Report