二、 Mysql安装,调试
2.1 安装包下载
切换到/software目录(基于本次教程)cd /software
执行下面命令:
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
下载安装包(直接复制所有命令,输入即可,部分时候可能因为网络问题,多次尝试)
2.2 安装mysql
执行该命令需要联网,注意虚拟机网络连接
yum install -y mysql-community-*-5.7.35-1.el7.x86_64.rpm
2.3 修改密码
开始mysql服务器并初始化密码
命令:systemctl start mysqld # 开启MySQL服务器
cat /var/log/mysqld.log | grep password # 查看默认初始生成的密码
以root用户登陆Mysql
命令:mysql -u root -p
设置密码等级并修改密码
set global validate_password_length=4;
set global validate_password_policy=0; # 设置密码等级
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘您的密码’; # 修改默认密码,注意替换后面的密码
2.4 创建用户并赋予权限
CREATE USER ‘test’@‘%’ IDENTIFIED BY ‘123456’; #创建“test”用户,设置为允许远程登录
grant all on . to ‘test’@‘%’; #赋予此用户所有数据库的所有权限(增删改查)
2.5 连接navicat软件
报错分析:防火墙未关闭
查看防火墙状态:systemctl status firewalld
关闭防火墙:systemctl stop firewalld
永久禁用:systemclt disable firewalld