Basic operation of Linux to mysql/mariadb database and Linux mysql add user, delete user, and grant of user rights

Source: Internet
Author: User

Article reference address: https://www.cnblogs.com/Glory-D/p/7518541.html, https://www.cnblogs.com/zhchoutai/p/6929103.html

Mysql-u root-p + Enter-u followed by user name,-p means password login required, first access to MySQL with root user

Such as:

mariadb>>status; -list current MySQL related status information, note to add a semicolon '; '

Mariadb>>show databases; -Show Database list

Mariadb>>use LXF; -Select Database Lxf

Mariadb>>show tables; -Displays a list of tables under the LXF database

Mariadb>>create database lxf;-Create the LXF, need to log in with the root user, the normal user does not have the right to create the database

Mariadb>>drop table Data Sheet name; -delete Table

Mariadb>>drop database name; -delete Database

mariadb>>quit; -Exit

Mariadb>>

Mariadb>>

Mariadb>>

Mariadb>>

Mariadb>>

User-Related:

1. View All Users:

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

2. New User:

CREATE USER ‘abc‘@‘localhost‘IDENTIFIED BY ‘XXXXXX‘; —会发现用户abc以及被添加成功

3, for the user authorization

Grant permissions on the database. * to [email protected] Login host identified by ' password ';

3.1 Grant partial permissions to the user: Grant Select,insert,delete,update on lxf.* to ABC identified by ' 123456 ';

Demo Sample:

3.2 Plus full permissions to the TestDB database grant all privileges on testdb.* to [email protected] identified by ' 1234 '; 3.3 Grant certain permissions to a user for all databases: Grant Select,delete,update,create,drop on * * to [e-mail protected] "%" identified by "1234"; 3.4 then you need to run the Refresh Permission command: Flush privileges; 4, delete the user: Delete from user Where user= ' test ' and host= ' localhost '; then refresh the permissions; Delete accounts and permissions: >drop user [email protected] '% ';
>drop user [email protected] localhost; 5, change the designated user password
Log in with Root:
Mysql-u root-p
To run the command:
Update Mysql.user set Password=password (' New password ') where user= "test" and host= "localhost";
Refresh permissions:
Flush privileges;

Basic operation of Linux to mysql/mariadb database and Linux mysql add user, delete user, and grant of user rights

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.