One, MySQL introduction and installation

1. Database Management System

Database management system DBMS is a large-scale software that manipulates and manages databases, and is used to establish, use and maintain databases. Database management systems are divided into RDBMS and NoSQL (Not only SQL).

  • The RDBMS
    relational database management system is more suitable for data with high security requirements and data with more complex relationships. Common RDBMS are MySQL, Oracle, MSSQL.
  • NoSQL
    non-relational database is suitable for high-performance access to data. It is generally used in conjunction with RDBMS. For big data processing and analysis, distributed architecture is better.
    Common NoSQL: key-value storage Redis and document storage MongoDB

2. Introduction to MySQL

MySQL is a small and medium-sized relational database management system suitable for all platforms. It is open source software with fast version updates, excellent performance and low price. The advantages of MySQL database are as follows:

  • Can handle large data with tens of millions of records
  • Support common SQL statement specifications
  • Portable row height, simple and compact installation
  • Good operating efficiency, network support with rich information
  • Simple debugging, management and optimization (compared to other large databases)

The commonly used MySQL versions are:

  • MySQL5.6 : 5.6.34 5.6.36 5.6.38 5.6.40
  • MySQL5.7 : 5.7.18 5.7.20 5.7.24

Three, MySQL installation

Remove mariadb environment

rpm -qa |grep mariadb
yum remove mariadb-libs-5.5.60-1.el7_5.x86_64 -y

Unzip software

tar xf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.20-linux-glibc2.12-x86_64 /application/mysql

Set environment variables

export PATH=$PATH:/application/mysql/bin
source /etc/profile

Create mysql user

useradd -M -s /sbin/nologin mysql

Create data storage directory and log storage directory

mkdir -p /data/mysql/data
mkdir -p /data/mysql/log
mkdir -p /data/mysql/socket

Create mysql.log, mysql-bin and mysql.sock

touch /data/mysql/log/{mysql.log,mysql-bin}
touch /data/mysql/socket/mysql.sock

Directory authorization

chown -R mysql.mysql /application/mysql
chown -R mysql.mysql /data/mysql

Edit configuration file

[mysqld]
user=mysql
basedir=/application/mysql
datadir=/data/mysql/data
socket=/data/mysql/socket/mysql.sock
log_error=/data/mysql/log/mysql.log
log_bin=/data/mysql/log/mysql-bin
server_id=6
port=3306
[mysql]
socket=/data/mysql/socket/mysql.sock

Start the database

/application/mysql/support-files/mysql.server start

Startup script

vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

Set automatic startup

systemctl enable mysqld.service

Set database password

set PASSWORD = PASSWORD('mysql');

Management authorization

grant all privileges on . to 'root'@'%' identified by 'mysql' with grant option;

Four, client login

1. sqlyog

One, MySQL introduction and installation

One, MySQL introduction and installation

2. navicat

One, MySQL introduction and installation

One, MySQL introduction and installation

Guess you like

Origin blog.51cto.com/12631595/2554719