时间:2021-07-01 10:21:17 帮助过:9人阅读
系统版本:CentOS Linux release 7.5.1804 (Core)
Mysql版本:5.7.24
关闭防火墙并禁止开机自启
systemctl stop firewalld.service
systemctl disable firewalld
关闭selinux
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/sysconfig/selinux
重启 reboot
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
basedir=/usr/local/mysql
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock
log-error=/var/lib/mysql/mysql.log
pid-file=/var/lib/mysql/mysql.pid
注:方式不限,上传即可!
tar xf mysql-5.7.24-el7-x86_64.tar
注:解压文件有两个,我们使用的是mysql-5.7.24-el7-x86_64.tar.gz
tar xf mysql-5.7.24-el7-x86_64.tar.gz
mv mysql-5.7.24-el7-x86_64 /usr/local/mysql
groupadd mysql
useradd -g mysql mysql
vi /etc/my.cnf
[mysqld]
user= mysql
port= 3306
socket= /tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/var/lib/mysql/data
log-error=/var/lib/mysql/mysql.log
pid-file=/var/lib/mysql/mysql.pid
character-set-server=utf8
collation-server=utf8_bin
注:从5.7.18开始support-files就没有my.cnf的模板了,所以要自己写了配置文件!
mkdir -p /var/lib/mysql/data
1)设置权限
chown -R mysql:mysql /var/lib/mysql/
2)初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql/data/&
注:mysql5.7初始化后,会产生一个 临时登录密码,在mysql.log日志中!
1)启动数据库
/usr/local/mysql/bin/mysql -u root –p
2)登录数据库
/usr/local/mysql/bin/mysql -u root –p
3)修改密码
set password=password(‘123456‘);
flush privileges;
1)查看mysql进程是否正常
ps -ef | grep mysql
2)查看 3306 端口是否开启
netstat -antupl | grep 3306
echo ‘export PATH=/usr/local/mysql/bin:$PATH‘>>/etc/profile
source /etc/profile
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
Centos7 二进制安装mysql5.7
标签:fir 注册 reboot bin service 检查 ble 变量 conf