Centos7.7安装mysql5.7.28二进制包方式部署

1、安装依赖包

yum -y install libaio


2、安装mysql软件
下载软件包:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz

tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql5.7
useradd -s /sbin/nologin -M mysql
mkdir -p /app/mysql5.7/{etc,logs,tmp}


3、初始化数据

最后一行会获得一个初始密码,请注意。

cd /app/mysql5.7/
bin/mysqld --initialize --basedir=/app/mysql5.7/ --datadir=/app/mysql5.7/data --user=mysql


4、修改配置文件

cd /app/
chown -R mysql .
vim /app/mysql5.7/etc/my.cnf
[mysqld]
daemonize = on
user = mysql
port = 3306
basedir = /app/mysql5.7
datadir = /app/mysql5.7/data
socket = /tmp/mysql.sock
bind-address = 0.0.0.0
pid-file = /app/mysql5.7/tmp/mysqld.pid
character-set-server = utf8
collation-server = utf8_general_ci
max_connections = 2408
log-error = /app/mysql5.7/logs/mysqld.log


5、systemd启动MYSQL服务

vim /lib/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
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/app/mysql5.7/bin/mysqld --defaults-file=/app/mysql5.7/etc/my.cnf
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStartus=1
PrivateTmp=false


6、启动服务

systemctl restart mysqld
systemctl enable mysqld

7、修改mysql root密码

vim /etc/profile.d/mysql.sh
export PATH=$PATH:/app/mysql5.7/bin
source /etc/profile.d/mysql.sh
mysql -uroot -p
alter user 'root'@'localhost' IDENTIFIED BY 'xxxxx';

 

你可能感兴趣的:(mysql,Centos7)