一 mysql安装
1。安装mysql,用rpm安装方式。这里用的版本是(mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar)
2。用tar解压mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar(解压后需要按顺序安装)
3。检查当前系统有没有安装mariadb
rpm -qa|grep mariadb
4。第2步中存在mariadb。就移除(mariadb-libs-5.5.65-1.el7.x86_64是在第2步中查到的)
rpm -e mariadb-libs-5.5.65-1.el7.x86_64 --nodeps
5。安装mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
6。安装mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
7。安装 mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
8。安装mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
9。安装mysql-community-server-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm --nodeps
10。安装mysql-community-devel-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.28-1.el7.x86_64.rpm
二 数据库初始化
1。使用initialize 初始化 且实例化mysql库
mysqld --initialize --user=mysql
2。查看默认的数据库密码
cat /var/log/mysqld.log
3。启动mysql服务
systemctl start mysqld.service
4。查看mysql启动状态
systemctl status mysqld.service
5。登录mysql
mysql -uroot -p
6。重新设置登录密码
set password=password('root');
7。关闭防火墙
systemctl stop firewalld
8。禁用防火墙
systemctl disable firewalld.service