当前位置:网站首页>MySQL introduction and installation (I)
MySQL introduction and installation (I)
2022-06-12 21:44:00 【Stay up late and soak wolfberry】
List of articles
1. MySQL Learning route
Chapter one Introduction and installation
Chapter two Architecture and basic management
The third chapter SQL Basics
Chapter four Index and Implementation plan
The fifth chapter Storage engine
Chapter six Log management
Chapter vii. Backup and recovery
Chapter viii. Master slave replication and architecture evolution
Chapter nine High availability and read / write separation architecture
Chapter ten Distributed architecture
Chapter ten Comprehensive optimization
Chapter 11 NoSQL-redis/mongodb/ES
Search engine database ranking :https://db-engines.com/en/ranking
2. MySQL Introduce
2.1 Data form
data : written words 、 picture 、 video ... Data representation of human cognition
Computer : Binary system 、16 Binary machine language
Based on the importance and complexity of the data , We may have different management methods .
What data is suitable for storage in the database ?
Of high importance
Data with complex relationships
2.2 Database management system DBMS
RDBMS: Relational database management system
It's more suitable for , Data with high security level requirements and data with complex relationships
NoSQL: Non relational database management system
Suitable for high performance data access , In general, it's cooperation RDBMS For use
For big data processing and Analysis , Distributed architecture is better at
2.3 Database management system type
RDBMS :
MySQL 、Oracle、MSSQL(SQL Server)、PG
NoSQL:Not Only SQL
key - value (key-value):Redis, memcached
file (document):Mongodb( Store historical orders 、 Running water )、ES( Search box )
3. MySQL product line
3.1 MySQL manufacturer
Oracle: MySQL Official edition
Redhat: MariaDB
Percona: PerconaDB
3.2 MySQL Version selection
5.6 :2021 year 2 Month stopped updating . Quit the stage of history immediately .
5.7 :5.7.31+
8.0 :8.0.20+
Version number designation :
The core system 5731
Edge system 8020
3.3 MySQL Software access
www.mysql.com ---> downloads
Enterprise Edition :Enterprise , The Internet industry generally does not choose .
Community version : choice , Enterprises use and learn to use
Source package :source code .tar.gz, Generally, when looking at the source code, look at the installation
Binary package :

Source package :
3.4 MySQL Installation mode
General binary version : Decompression is used immediately. ( The green version )
rpm、yum edition : download rpm Package or configuration yum Source
Source package : Compilation and installation , Very slow
4. MySQL-5.7.28 Binary package installation
4.1 Environmental preparation
(1) Get ready Centos 7.6 virtual machine
[root@db01 ~]# hostname -I
10.0.0.61
[root@db01 ~]# hostname
db01
(2) Clean up the historical environment
[root@db01 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
mariadb-server-5.5.68-1.el7.x86_64
mariadb-5.5.68-1.el7.x86_64
[root@db01 ~]# yum remove mariadb-libs.x86_64 -y
(3) Create users and groups
[root@db01 ~]# useradd mysql -s /sbin/nologin
[root@db01 ~]# id mysql
uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
(4) Create related directories
# Create a software catalog
[root@db01 ~]# mkdir -p /app/database/
# Create a data directory
[root@db01 ~]# mkdir -p /data/3306/
# Create a log directory
[root@db01 ~]# mkdir -p /binlog/3306/
(5) Set the permissions
[root@db01 ~]# chown -R mysql.mysql /app/ /data/ /binlog/
4.2 Upload and unzip MySQL Software
[root@db01 ~]# cd /app/database/
[root@db01 database]# tar xf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
[root@db01 database]# ln -s mysql-5.7.30-linux-glibc2.12-x86_64 mysql
4.3 Set the environment variable
[root@db01 ~]# vim /etc/profile
# Add the following lines :
export PATH=/app/database/mysql/bin:$PATH
# Effective configuration
[root@db01 ~]# source /etc/profile
4.4 Initialize system library table
Tips :rmp The package automatically completes the initialization operation
# Installation dependency , Prevent initialization error
[root@db01 ~]# yum install -y libaio-devel
# To initialize
[root@db01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
# The lack of libaio-devel rely on , Initialization error :
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
# An error that is easy to report :
[root@db01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
2022-06-08T14:03:39.492759Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-06-08T14:03:39.494239Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2022-06-08T14:03:39.494260Z 0 [ERROR] Aborting
# reason + solve : If an error occurs during the first initialization , This error may be reported during the second initialization
[root@db01 ~]# rm -rf /data/3306/*
[root@db01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
Expand :
# 5.7 The initialization mode of subsequent versions
# mysqld --initialize-insecure --user=mysql --basedir= Software path --datadir= Data path
(1) mysqld --initialize
Will generate 12 Bit random temporary password ( Administrator user ), Four types of password complexity .
Temporarily generate password , Can only be used to log in . Cannot be used to manage databases . Reset it the first time you log in
[root@db01 data]# mysql -uroot -p'Uh0*xe(eLw(W'
mysql> create database test;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement
mysql> alter user root@'localhost' identified by '123';
mysql> create database test;
Or change the password like this :
[root@db01 data]# mysqladmin -uroot -p password [email protected]
# Enter the initialization password
Enter password:
(2) mysqld --initialize-insecure
The administrator password is empty
# 5.7 Initialization mode of previous version ( for example 5.6)
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir= Software installation path --datadir= Data directory
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/app/database/mysql --datadir=/data/3306/
4.5 Profile Settings
[root@db01 ~]# cat > /etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/app/database/mysql
datadir=/data/3306/
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
EOF
4.6 Get ready MySQL The startup script
[root@m01 ~]# cd /app/database/mysql/support-files/
# Copy mysql To the system software management directory
[root@m01 support-files]# cp mysql.server /etc/init.d/mysqld
# centos6
[root@m01 ~]# service mysqld start
Starting MySQL.Logging to '/data/3306/m01.err'.
SUCCESS!
# centos7
# take /etc/init.d/mysqld Add to systemd In management
[root@m01 ~]# chkconfig --add mysqld
[root@m01 ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@m01 ~]# systemctl start mysqld
边栏推荐
- Yanghui triangle code implementation
- 建立高可用的数据库
- SQL调优指南笔记6:Explaining and Displaying Execution Plans
- MySQL master-slave replication
- 测试基础之:单元测试
- Shell script Basics
- Ansible-大总结(六)
- KDD2022 | GraphMAE:自监督掩码图自编码器
- Smart management of green agriculture: a visual platform for agricultural product scheduling
- C language learning notes (II)
猜你喜欢

Build a highly available database

Shell script Basics

The Post-00 financial woman with a monthly salary of 2W conquered the boss with this set of report template

Graphics2D类基本使用

MySQL master-slave replication

SQL tuning guide notes 15:controlling the use of optimizer statistics

KDD2022 | GraphMAE:自监督掩码图自编码器

SQL调优指南笔记14:Managing Extended Statistics

MySql主从复制

SQL tuning guide notes 13:gathering optimizer statistics
随机推荐
drf 接收嵌套数据并创建对象, 解决:drf NOT NULL constraint failed
ZGC concurrent identity and multi view address mapping in concurrent transition phase
JVisualVM初步使用
Linux backup MySQL
六月集训(第11天) —— 矩阵
建立高可用的数据库
【QNX Hypervisor 2.2 用户手册】4.3 获取host组件
zgc的垃圾收集的主要階段
如何自己动手写一个vscode插件,实现插件自由!
SQL调优指南笔记12:Configuring Options for Optimizer Statistics Gathering
NIO使用指南
OceanBase 社区版 OCP 功能解读
模块八:设计消息队列存储消息数据的MySQL表
What is the difference between volatile variables and atomic variables?
[leetcode] 573 complex multiplication (conversion between characters and numbers)
selenium操作元素遇到的异常
Oracle LiveLabs实验:Introduction to Oracle Spatial
lambda表达式与流优化代码
回文链表及链表相交问题(和心怡的人相交)你真的会了吗?
Ansible playbook和变量(二)