MySQL database brief introduction and compilation and installation

Simple understanding of the database

Database (database), in short, can be regarded as an electronic file cabinet-a place for storing electronic files. Users can perform operations such as adding, intercepting, updating, and deleting data in the file.
The so-called "database" is a collection of data stored together in a certain way that can be shared by multiple users, with as little redundancy as possible, and independent of the application.
A database is composed of multiple tablespaces.

Database understanding

Data
Symbol records describing things are called data (Data),
including numbers, text, graphics, images, sounds, file records, etc.
Stored in a unified format in the form of "records"
Each row is called a record
Each column is called a field

The table
organizes the different records together to form a "table
is used to store specific data

Database A
database is a collection of tables, a warehouse
for storing data, and related data stored in a certain organization.
Insert picture description here

Database development

The first-generation database
Since the 1960s, the first-generation database system has come out. They are database systems of hierarchical model and network model, which provide strong support for unified management and sharing of data. The
second-generation database
In the early 1970s, the second-generation database-relational database began to appear
in the early 1980s, IBM Corporation DB2, the second-generation relational database system, came out. As the relational database of the second-generation database system, it began to gradually replace the database of the hierarchical and mesh model, becoming the dominant database and becoming the mainstream of the industry.
So far, the relational database system still occupies the main position of database applications. Since the
third generation of databases
began in the 1980s, various new database systems adapted to different fields have been emerging, such as engineering databases, multimedia databases, graph databases, and intelligent databases. Distributed databases and object-oriented databases, etc., especially object-oriented database systems, are favored by people due to their strong practicability and wide adaptability.
In the late 1990s, a situation where a variety of database systems jointly support applications was formed
. Regarding business applications, relational databases still dominate, but some new elements have been added to mainstream business database systems.
For example, the "relation-object" database model supported by Oracle

Mainstream database at this stage

MySQL (acquired by Oracle) is
free, open source, and small.
sql server (product of Microsoft) is
for Windows operating system.
Simple and easy to use.
Access (product of Microsoft) is
for Windows. It
is a member of Microsoft office suite applications
oracle (Oracle) Product)
for all mainstream platforms
Safe, complete, and complex
db2 (IBM) For
all mainstream platforms
Large, secure, and complete
Sybase (Sybase) For
all mainstream platforms
Large, secure, and complete The
world’s largest

Relational Database

Relational database system is a database system based on relational model, and its basic concept comes from relational model

The relational model is based on the theory of relational algebra, and the data structure uses a simple and easy-to-understand two-dimensional data table, which can be directly represented by a simple "entity-relationship" (ER) diagram

The ER diagram contains three elements: entity (data object), relationship and attribute. E.g
Insert picture description here

entity:

Also called an instance, it corresponds to "events" or "
things" that can be distinguished from other objects in the real world , such as bank customers, bank accounts and other
attributes:

For a certain characteristic of an entity, an entity can have multiple attributes. For example, each entity in the "bank customer" entity set has attributes such as name, address, and telephone number.
Contact:

Correspondence between entity sets is called association, also known as relationship. For example, there is a "savings" relationship between a bank customer and a bank account.
The collection of all entities and their connections constitutes a relational database

There will be codes in relational database tables, called primary keys, which have unique and non-empty characteristics

The storage structure of the relational database is a two-dimensional table, and the data reflecting things and their connections are stored in the form of a table

In each two-dimensional table, each row is called a record, used to describe the information of an object; each column is called a field, used to describe an attribute of the object

Application examples of relational databases:

12306 user information system
Taobao account information system, Alipay account system mobile, telecommunications, China Unicom mobile phone number information system, billing system bank user account system
website user information system

Non-relational database

Non-relational databases are also called NOsQL (Not Only SQL), and the stored data is not based on the relational model and does not require a fixed table format

As a supplement to the relational database, non-relational databases play high efficiency and high performance in the era of increasingly rapid development of websites

Advantages of non-relational databases

The demand
for high concurrent read and write of the database The demand for efficient storage and access of massive data The demand for
high scalability and high availability of the database
Most of NoSQL exists in the form of files

Relational database storage

Key-value method (key-value), storage, deletion, and
modification of data based on keys. Column-oriented storage (column-oriented), a method of storing related data in a column family
document. The database is composed of a series of data items, each Data items have names and corresponding values.
Graphic mode, entity is vertex, relationship is edge, and data is saved as a graph.
Non-relational database product

Memcached is an open source, high-performance cache system with distributed memory objects, which stores data in a key-value manner

Cache data to reduce database pressure and speed up access speed.
Accelerate dynamic web applications.
Cached content is stored in memory.
Redis is also a key-vaue method to store data. Data is also stored in memory, but data is written to disk regularly.

Compared with Memcached, it has the following features.
Supports memory cache.
Supports persistence.
More data types.
Supports clusters and distribution.
Supports queues.
Database log files are used for recovery. Oracle logs are called redo log groups.

For example:
Ali oss object storage adopts the idea of ​​oracle redo log group.
Ali oss data is in triplicate. It is
a relay log (binary log) of Pangu system Redis.
Redis application example.
Database front-end cache
session sharing.
When you need to cache except key/value when more data types outside
when the cached data needs to be stored for a long time

MySQL compile and install

Installation environment dependency

[root@5centos ~]# yum -y install gcc \
> gcc-c++ \
> ncurses \     ##字符终端依赖包
> ncurses-devel \
> bison \       ##函数库
> cmake

Compile and install

[root@5centos mysql-5.7.20]# useradd -s /usr/sbin/nplogin mysql
[root@5centos mysql-5.7.20]# tar zxvf boost_1_59_0.tar.gz 
[root@5centos mysql-5.7.20]# mv boost_1_59_0 /usr/local/boost
[root@5centos mysql-5.7.20]# tar zxvf mysql-boost-5.7.20.tar.gz 
[root@5centos mysql-5.7.20]# cd mysql-5.7.20/
[root@5centos mysql-5.7.20]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DSYSCONFDIR=/etc \
> -DSYSTEMD_PID_DIR=/usr/local/mysql \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DWITH_BOOST=/usr/local/boost \
> -DWITH_SYSTEMD=1
[root@5centos mysql-5.7.20]# make && make install
[root@5centos mysql-5.7.20]# chown -R mysql:mysql /usr/local/mysql/

Edit configuration file environment variables

[root@5centos /]# vim /etc/my.cnf
##删除全部,敲入下面几行
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

[root@5centos /]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
[root@5centos /]# echo 'export PATH' >> /etc/profile
[root@5centos /]# source /etc/profile

initialization

[root@5centos local]# cd mysql/
[root@5centos mysql]# bin/mysql \
> --initialize-insecure \
> --user=mysql \
> --basedir=/usr/local/mysql \
> --datadir=/usr/local/mysql/data 

Start the service and verify the database

[root@5centos /]# mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@5centos mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 Source distribution
……省略部分……
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

Guess you like

Origin blog.csdn.net/Ora_G/article/details/108024961