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