在安裝mysql5之前,我們需要先安裝一些依賴包:
yum install -y libaio yum install -y net-tools yum install -y perl
接著,我們下載mysql5的離線安裝包:
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.28-1.el7.x86_64.rpm-bundle.tar
將下載好的.tar文件解壓:
tar -xvf mysql-community-server-5.7.28-1.el7.x86_64.rpm-bundle.tar
安裝rpm包:
rpm -Uvh mysql-community-common-5.7.28-1.el7.x86_64.rpm rpm -Uvh mysql-community-libs-5.7.28-1.el7.x86_64.rpm rpm -Uvh mysql-community-client-5.7.28-1.el7.x86_64.rpm rpm -Uvh mysql-community-server-5.7.28-1.el7.x86_64.rpm
我們需要修改mysql配置文件:
vi /etc/my.cnf
在[mysqld]后面添加以下內容:
lower_case_table_names=1 default-storage-engine=INNODB character-set-server=utf8 collation-server=utf8_general_ci explicit_defaults_for_timestamp =true
保存配置文件,啟動mysql服務:
systemctl start mysqld systemctl enable mysqld
安裝完成后,我們需要設置root用戶的密碼:
mysql_secure_installation
根據提示進行操作即可。