参考文章:https://www.cnblogs.com/helf/p/11244711.html
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
2.查看
查看:[root@localhost bin]# rpm -qa|grep mariadb
卸载:[root@localhost bin]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost src]# yum install libaio
[root@localhost src]# yum install perl
[root@localhost src]# yum install net-tools
安装依赖时会询问你是下载并安装还是下载或者不下载。(输入y回车,下载并安装即可。)
[root@localhost src]# tar -xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
[root@localhost src]# rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm [root@localhost src]# rpm -ivh mysql-community-libs-5.7.24-1.el7.x86_64.rpm [root@localhost src]# rpm -ivh mysql-community-client-5.7.24-1.el7.x86_64.rpm [root@localhost src]# rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm
查看mysql启动状态
[root@localhost src]# service mysqld status
启动mysql active(running)代表启动成功
[root@localhost src]# service mysqld start
查看临时密码: [root@localhost src]# grep password /var/log/mysqld.log 用临时密码登录mysql [root@localhost src]# mysql -uroot –p 修改成新的密码 mysql> set password = password("root"); //如提示密码策略问题 mysql> set global validate_password_length=4;//设置密码为4位 mysql> set global validate_password_policy=0;//策略要求置为LOW
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
#开启关闭防火墙指令 systemctl start firewalld.service #查看开放的端口列表 firewall-cmd --list-ports 开放306端口 firewall-cmd --zone=public --add-port=3306/tcp --permanent # --zone 作用域 # --add-port=5121/tcp 添加端口,格式为:端口/通讯协议 # --permanent 永久生效,没有此参数重启后失效 #装载配置 firewall-cmd --reload #重启防火墙 systemctl stop firewalld.service