Get the App
SLTechnology News&Howtos  ›  Database  › 

"Linux Rookie getting started 2" mariadb Service

Shulou Source: shulou.com Published: 2022-06-01 14:31:46 09月23日 Update

Learn to use mariadb database

1.yum search mariadb queries the package he wants to pack.

2.yum install mariadb-server.x86_64-y installation service

3.netstat-antlpe | grep mysql checks that the API loopback interface is 127.0.0.1

Vim / etc/my.cnf configuration interface

Skip=networking=1

Log=arror=/var/log/marriadb.log

Pid-file=/var/run/mariadb.pid

Local connections are made only through socket files, blocking all TCP/IP connections from the network

4.systemctl stop firewalld.service

5.systemctl start mariadb

6.mysql_secure_installation opens the database for the first time for initial configuration

7.mysql-uroot-p

Redhat standard enters database format

8.SHOW DATABASES; display database

9.USE mysql; enters the database

10.SHOW TABLES; displays tables in the database

11.DESC user; looks at the data structure of the user table

12.FLUSH PRIVILEGES; refresh database information

13.SLECT host.user,password FROM user; queries the host,user,password field in the user table

14. Insert, delete, create operation of database

CREATE DATABASE westos; creates westos database

USE westos

CREATE TABLE linux (create table, username,password field

Username varchar (15) not null

Password varchar (15) not null)

SELECT * FROM mysql.user; queries the user table under the mysql library

ALTER TABLE linux ADD age varchar (10); add age to the linux table

ALTER TABLE linux DROP age; Delete age

ALTER TABLE linux ADD age VARCHAR (5) AFTER name; adds age after the name field

SHOW TANLES

DESC linux

INSERT INTO linux values ('user1','passwd1')

Insert the value username = user1,password = password1 in the linux table

15.UPDATE linux SET password=password ('passwd2') WHERE username=user1

Change the password of user1 in the linux table to password2

16.DELETE FROM linux WHERE username=user1

Delete all the contents of user1 in the linux table

17.GRANT SELECT ON *. * to user1@localhost IDENTIFIED BY 'passwd1'

The authorized user1 password is passwd1 and can only query all the contents of the database locally.

18.GRANT ALL ON mysql.* to user2@'%' IDENTIFIED BY 'passwd2'

The authorized user2 password is passwd2, you can login to mysql from any remote host, and you can operate on the mysql database at will.

Tags: Data database query field password interface content configuration service host information loopback socket data structure file standard format first time structure network Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi MariaDB NVidia Redmi