Installation and deployment of mysql on linux

One, yum install MySQL

1. Download the rpm package

First enter the MySQL download official website https://dev.mysql.com/downloads/mysql/

Note : When installing this method, although the installation package is downloaded locally, there are dependencies during the installation process, so the installation network source must be modified to contact the dependencies

You need to choose which one according to your own situation. Insert picture description here
Then choose the first one to download Insert picture description here
. After downloading, copy the downloaded package to the virtual machine, and then install it on the virtual machine

Installation steps:
1.rpm -e mariadb-libs postfix (uninstall mariadb, linux default database)
2.groupadd mysql
3.useradd -g mysql mysql
4.mkdir mysql
5.tar -xf mysql-8.0.22-1.el7 .x86_64.rpm-bundle.tar -C mysql (-C unzip to the specified directory)
Insert picture description here
6. Then proceed to yum installation
7.yum localinstall mysql-community-client-8.0.22-1.el7.x86_64.rpm mysql-community- server-8.0.22-1.el7.x86_64.rpm mysql-community-libs-8.0.22-1.el7.x86_64.rpm mysql-community-common-8.0.22-1.el7.x86_64.rpm
Insert picture description here
appeared this What to do, don’t worry, click where is the error
8.yum localinstall mysql-community-client-8.0.22-1.el7.x86_64.rpm mysql-community-server-8.0.22-1.el7.x86_64.rpm mysql -community-libs-8.0.22-1.el7.x86_64.rpm mysql-community-common-8.0.22-1.el7.x86_64.rpm mysql-community-client-plugins-8.0.22-1.el7.x86_64 .rpm
9. So far, it's installed

Start:
1.systemctl start mysqld
2. systemctl enable mysqld (start on boot)

Check the password and modify the password:
1. grep "temporary password" /var/log/mysqld.log
box out is the password we found Insert picture description here
2. Modify the password
Insert picture description here

2. Official source installation

Disadvantages: slow

Enter MySQL official website https://dev.mysql.com/downloads/repo/yum/ download
Which version to download Choose according to your own situation Insert picture description here
1.yum install mysql80-community-release-el7-3.noarch.rpm
2.yum list | grep "mysql-community"
3.yum install mysql-community-client mysql-community-server

Second, install MySQL in binary

1. Download the glibc version of mysql, http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-8.0/

2. Install the system dependency package, yum -y install make gcc-c++ cmake bison-devel ncurses-devel readline-devel libaio-devel perl libaio wget lrzsz vim libnuma* bzip2 xz

3. Close selinux
setenforce 0 # temporarily close
sed -i's/SELINUX=enforcing/SELINUX=disabled/' #permanently close

4. Modify the parameters of the configuration file
vim /etc/security/limits.conf
Insert picture description here

5. Modify the kernel parameter
Insert picture description hereInsert picture description here
sysctl -p # effective immediately

6.mysql installation configuration:

(1) Unzip the installation package tar xjf mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz -C /opt/

(2) Make a soft connection to /usr/bin
[root@localhost ~]# cd /opt/
[root@localhost opt]# cd /usr/local/
[root@localhost local]# ln -s /opt/mysql- 8.0.19-linux-glibc2.12-x86_64 mysql/

(3) Create user
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql -d /home/mysql -s /sbin/nologin

(4) Modify directory permissions
[root@localhost local]# chown -R mysql.mysql mysql/*

(5) Initialize the database
[root@localhost local]# cd mysql/
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/ local/mysql/data

(6) Create a configuration file. If the configuration file exists, you need to comment
[root@localhost mysql]# if [-f /etc/my.cnf ]; then mv /etc/my.cnf "/etc/my.cnf date +%Y%m%d%H%m.. bak"; fi

(7) Modify the configuration file
[root@localhost profile.d]# vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
server_id=10
port = 3306
user = mysql
character-set-server = utf8
default_storage_engine = innodb
log_timestamps = SYSTEM
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mysqld.pid
max_connections = 1000
max_connect_errors = 1000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
#####=============================[innodb] ==============================

innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path=ibdata1:10M:autoextend#####================================[log]
============================

log_error = /var/log/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /var/log/mysql-slow.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

(8) Provide sysv service script for MySQL
[root@localhost profile.d]# cd /usr/local/mysql/
[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init. d/mysqld
[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld

(9) Start MySQL
[root@localhost mysql]# chkconfig --add mysqld --add as a system service
[root@localhost mysql]# chkconfig mysqld on --start automatically after booting
[root@localhost mysql]# systemctl start mysqld

(10) Add the MySQL bin directory to the PATH environment variable, edit the /etc/profile file, and use the mysql client command
[root@localhost ~]# cd /etc/profile.d/
[root@localhost ~]# vim mysql. rc
export PATH=$PATH:/usr/local/mysql/bin
#Add this one root@localhost ~]# source mysql.sh

(11)数据库登录并改密码
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 MySQL Community Server - GPL
Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> alter user ‘root’@‘localhost’ identified by ‘ABC123.com’; #修改密码为ABC23.com

Guess you like

Origin blog.csdn.net/qq_44944641/article/details/112756742