文章内容输出来源:拉勾教育Java高薪训练营;
服务器:Linux Centos7.4
Mysql版本:5.7.28
链接: https://pan.baidu.com/s/1qmm_nnoW8dJ1d7qmtokrbQ 提取码: 6c6y
解压压缩包
tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
有些linux版本可能会自带mariadb,需要先删掉
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
安装mysql
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
#这一步可能安装不上需要插件,先安装插件:
# yum install libaio
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.28-1.el7.x86_64.rpm
#初始化mysql,会生成mysql密码
mysqld --initialize --user=mysql
#查看下生成的mysql密码
cat /var/log/mysqld.log
#注册为自启动服务并启动
systemctl start mysqld.service
#查看下状态
systemctl status mysqld.service
登录mysql
mysql -uroot -p输入临时密码
#修改密码 并且授权远程访问
set password=password('root');
use mysql;
grant all on *.* to root@localhost identified by 'root';
grant all on *.* to root@'%' identified by 'root';
flush privileges;
#关闭防火墙一些东西,以免不能远程访问
systemctl stop iptables
systemctl stop firewalld
#永久关闭防火墙
systemctl disable firewalld.service
#mysql启动命令
service mysqld start
#mysql停止命令
service mysqld stop
#mysql重启命令
service mysqld restart
完成mysql的安装