[root@node2 software]# rz -E
rz waiting to receive.
[root@node2 software]# ls
mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@node2 software]# useradd -r -M -s /sbin/nologin mysql
[root@node2 software]# id mysql
uid=997(mysql) gid=994(mysql) groups=994(mysql)
[root@node2 software]#
[root@node2 software]# yum -y install libncurses* tar chrony
[root@node2 software]#
[root@node2 software]# systemctl restart chronyd
[root@node2 software]# systemctl enable chronyd
[root@node2 software]# hwclock -w
[root@node2 software]# timedatectl
Local time: Mon 2024-08-19 00:08:58 CST
Universal time: Sun 2024-08-18 16:08:58 UTC
RTC time: Sun 2024-08-18 16:08:58
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
[root@node2 software]#
[root@node2 software]# tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local
[root@node2 software]# cd /usr/local/
[root@node2 local]# ls
bin etc games include lib lib64 libexec mysql-5.7.37-linux-glibc2.12-x86_64 sbin share src
[root@node2 local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.37-linux-glibc2.12-x86_64/'
[root@node2 local]#
[root@node2 local]# chown -R mysql.mysql mysql/
[root@node2 local]# mkdir /opt/data
[root@node2 local]# chown -R mysql.mysql /opt/data/
[root@node2 local]# yum -y install libaio
[root@node2 local]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data/
#初始化
[root@node2 local]# cd mysql
[root@node2 mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@node2 mysql]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
'/usr/local/include/mysql' -> '/usr/local/mysql/include/'
[root@node2 mysql]#
[root@node2 mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@node2 mysql]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@node2 mysql]# ldconfig
[root@node2 mysql]#
[root@node2 mysql]# vim /etc/my.cnf
[root@node2 mysql]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
[root@node2 mysql]#
[root@node2 mysql]# cd /usr/local/mysql
[root@node2 mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@node2 mysql]# cd support-files/
[root@node2 support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@node2 support-files]# vim mysql.server
basedir=/usr/local/mysql
datadir=/opt/data
# 补全这两行(工作目录和数据目录)
[root@node2 support-files]#
[root@node2 support-files]# vim /usr/lib/systemd/system/mysqld.service
[root@node2 support-files]# cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=mysql sercer daemon
After=network.targe
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
[root@node2 support-files]#
[root@node2 support-files]# systemctl daemon-reload
[root@node2 support-files]# systemctl restart mysqld
[root@node2 support-files]# systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@node2 support-files]#
[root@node2 support-files]# cd
[root@node2 ~]#
[root@node2 ~]# /usr/local/mysql/bin/mysql -u root -e "set password=password('123456')"
[root@node2 ~]#
[root@node2 ~]# vim /etc/profile
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
#写入到最后一行
[root@node2 ~]# source /etc/profile
[root@node2 ~]#
[root@node2 ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>