鲁氏汤包王 2020-06-11
[ ~]# rm -fr /etc/yum.repos.d/* curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [ ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[ ~]# yum install net-tools vim tree htop iftop gcc gcc-c++ glibc iotop lrzsz sl wget unzip telnet nmap nc psmisc dos2unix bash-completion bash-completion-extra sysstat libaio-devel -y
到此安装完成 [ ~]# systemctl stop firewalld [ ~]# sed -i ‘/^SELINUX=/c SELINUX=disabled‘ /etc/selinux/config
[ ~]# echo ‘* - nofile 65535‘ >> /etc/security/limits.conf
[ ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[ ~]# rpm -qa |grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 [ ~]# yum remove mariadb-libs-5.5.60-1.el7_5.x86_64
[ ~]# useradd -s /sbin/nologin mysql
[ ~]# mkdir /application
[ ~]# tar xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz -C /application/ [ ~]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql #重命名
[ /application]# vim /etc/profile #加入这条配置信息 export PATH=/application/mysql/bin:$PATH [ /application]# source /etc/profile
[ /application]# mkdir /data/mysq/data -p [ /application]# chown -R mysql.mysql /data
[ /application]# mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
说明:
--initialize 参数:
\1. 对于密码复杂度进行定制:12位,4种
\2. 密码过期时间:180
\3. 给用户设置临时密码
[ ~]# cat >/etc/my.cnf <<EOF [mysqld] user=mysql basedir=/application/mysql datadir=/data/mysql/data socket=/tmp/mysql.sock server_id=6 port=3306 [mysql] socket=/tmp/mysql.sock EOF
[ /application]# cd /etc/init.d/ [ /etc/init.d]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld [ /etc/init.d]# netstat -lntp|grep 3306 tcp6 0 0 :::3306 :::* LISTEN 25760/mysqld [ /etc/init.d]# ps -ef|grep 3306 mysql 25760 25594 0 10:35 pts/0 00:00:00 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/data/mysql/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=mysqlJX.err --pid-file=/data/mysql/data/mysqlJX.pid --socket=/tmp/mysql.sock --port=3306 root 25796 13111 0 10:37 pts/0 00:00:00 grep --color=auto 3306
cat >/etc/systemd/system/mysqld.service <<EOF [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 EOF
[ ~]# systemctl start mysqld [ ~]# systemctl enable mysqld Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /etc/systemd/system/mysqld.service.
[ ~]# grant all on *.* to ‘localhost‘ identified by ‘123456‘;
grant all on *.* to ‘wxw‘ identified by ‘123‘;