Cyber Security Day21 - Database Knowledge
Others
2023-08-18 19:26:12
views: null
1. What is a database
A database is a warehouse for storing data, and this warehouse is more special
2. Why do you need a database (categorization is not clear)
store static data
On the storage server: pictures, videos, compressed packages
On the web server: html,js,css,php,python,java
In the database: text: articles, orders, commodities
interact with dynamic data
For e-commerce websites, these functions must interact with the database. Registered member, logged in member, purchase order, payment, logistics tracking, evaluation
Database administrator: DBA, high salary
3. Types of databases
3.1 Relational database
Essence: two-dimensional data table
Representative products: MySQL, oracle, sql server
oracle: At present, there are only stocks and no increments, and most of them will be replaced in the next three years in China
MySQL: the most popular Internet scene
sql server: Microsoft product
Access: access using sql language
Scenario: dynamic website backend
Advantages: data security is fully guaranteed
Disadvantages: low access efficiency, difficult expansion
3.2 NOSQL database
Positioning: a supplement to relational databases, not a substitute
Features: Not particularly related to data security, the core is high concurrency and large traffic
Products: memcach (memory database), redis (memory database), mongodb (document database)
3.3 new sql (domestic database) distributed database
Type: tidb, ob, Gaussian db, Dameng
Positioning: Domestic, large concurrency, large traffic, large data volume
Architecture: Distributed Database
3.4 Cloud database
Alibaba Cloud RDS, Tencent Cloud TDSQL
4. mysql relational database
features
Relational Database
Use sql statement management
Commonly used by Internet companies (free, open source, stable, active community, large concurrent solutions, data security)
mysql is almost equal to mariadb so learn the latter
5. Install mariadb
Install mariadb: yum install mariadb-server mariadb -y
Startup and autostart 方法一[ root@oldboy ~] systemctl start mariadb
方法二[ root@oldboy ~] systemctl enable mariadb
Check: ss -lnt|grep 3306
(if the result is red, it is right) or ps -ef|grep mysqld
Log in: mysql
Database data directory and error log
Order: rpm -ql mariadb-server
Important directories in the results
Database log: /var/lib/mysql
Error log: /var/log/mariadb/mariadb.log
Troubleshooting after installation
View status: grep -i error /var/log/mariadb/mariadb.log
The new data is installed normally and cannot be started. Try the method
rpm -e --nodeps mariadb-server mariadb
rm -fr /var/lib/mysql
yum install mariadb-server mariadb -y
6. SQL Structured Query Language
SQL classification
DDL (Data Definition Language): Responsible for managing database basic data (except tables), keywords create, alter, drop, etc.
DCL (Data Control Language): operation and maintenance personnel need to master, keywords commit, rollback, etc.
DML (Data Manipulation Language): operate on the data in the database table, keywords insert, delete, update, etc.
DQL(Data Query Language): keyword select, etc.
7. Set password for mariadb
Set a password for the administrator root: mysqladmin password oldboy123
Log in after setting the root password: mysql -uroot -p
Modify password: mysqladmin -uroot -p original password password new password
8. How to retrieve MySQL root password
stop database process
pkill mysqld
(kill the mysql process, the process name is mysqld)
ps -ef|grep mysql
(Check to see if the mysql process has been stopped)
Skip grant table (–skip-grant-table), skip network startup (–skip-network)
/usr/bin/mysqld_safe --skip-grant-table --skip-network &
ps -ef|grep mysql
Login and change password [ root@web01 ~] mysql
MariaDB> UPDATE mysql.user SET password = PASSWORD( "oldboy123" ) WHERE user = 'root' and host = 'localhost' ;
MariaDB> flush privileges;
MariaDB> quit
restart mysql
Kill the mysql service: pkill mysqld
Check progress: ps -ef|grep mysql
start up: systemctl start mariadb
Check port: ss -lntup|grep 3306
Login test: mysql -uroot -poldboy123
Origin blog.csdn.net/m0_73293867/article/details/131927377