Basic operation of MySQL based on Linux operating system (III)

Source: Internet
Author: User

Basic operation of MySQL based on Linux operating system (III)

    • Knowledge Point one: View all users in the MySQL database

Command: SELECT DISTINCT concat (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;

Note: (1) keyword DISTINCT is used to return only different values.

Syntax: SELECT DISTINCT column name from table name

(2) TheSQL concat function is used to concatenate two strings together to form a single string.

Compare the usage of both:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/8F/9C/wKioL1jm9erRLmgbAAAuu7vUGys548.png "style=" float : none; "title=" MySQL view user. PNG "alt=" Wkiol1jm9errlmgbaaauu7vugys548.png "/>

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/8F/9D/wKiom1jm9evzhhgfAAAnrkJB2hU792.png "style=" float : none; "title=" MySQL View user 2. PNG "alt=" Wkiom1jm9evzhhgfaaanrkjb2hu792.png "/>

    • Knowledge Point two: View the permissions of a specific user in a database

(1) Command: Show grants for ' cacti ' @ ' 127.0.0.1 ';

As follows:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8F/9C/wKioL1jm9vaxTMTCAAAid4W8nk0949.png "title=" MySQL permissions. PNG "alt=" Wkiol1jm9vaxtmtcaaaid4w8nk0949.png "/>

(2) Command: SELECT * from Mysql.user where user= ' cacti ' \g;

As follows:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/8F/9D/wKiom1jm-EDzTOoiAAA6__E38Jw634.png "title=" 11. PNG "alt=" Wkiom1jm-edztooiaaa6__e38jw634.png "/>

    • Knowledge Point three: Viewing the user table structure requires specific items that can be queried in conjunction with the table structure

Order: desc Mysql.user;

As follows:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/8F/9D/wKiom1jm-OWByaT3AAA0KtpfJv0536.png "title=" 11. PNG "alt=" Wkiom1jm-owbyat3aaa0ktpfjv0536.png "/>

    • Knowledge Point four: delete users

Command: Delete from mysql.user where user= ' cacti ' and host= ' 127.0.0.1 ' \g;

As follows:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/8F/9C/wKioL1jm_M6REGfWAAAMOgclQJ0536.png "style=" float : none; "title=" 11.PNG "alt=" Wkiol1jm_m6regfwaaamogclqj0536.png "/>

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/8F/9D/wKiom1jm_M6CVsCNAAAnjndlGNs132.png "style=" float : none; "title=" 22.PNG "alt=" Wkiom1jm_m6cvscnaaanjndlgns132.png "/>

Note:mysql>flush privileges; (Refresh database)

Mysql>drop database TestDB; Delete a user's database

This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1913714

Basic operation of MySQL based on Linux operating system (III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.