- 安装VMware
- 下载centos7镜像
- https://www.centos.org/download/
- 打开VMware导入镜像
- 设置用户名和密码
- ip addr查看本机ip地址, ens33下面的地址就是ip地址
- 开放linux3306端口
- sudo firewall-cmd --add-port=3306/tcp --permanent
- sudo firewall-cmd --reload
- 确认端口是否开放
- sudo firewall-cmd --list-ports | grep 3306
- 记住ip地址,使用final-shell连接
- 上传mysql安装包到root目录下
- mysql安装包:
- 链接:https://pan.baidu.com/s/1PbJZfDWilh_ms1PFiOJkOw?pwd=6666
- 提取码:6666
- 创建目录并解压
- mkdir mysql
- tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C mysql
- 安装mysql
cd mysql
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
yum install openssl-devel
rpm -ivh mysql-community-devel-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm
- 启动
systemctl start mysqld
systemctl restart mysqld
systemctl stop mysqld
- 查询密码
- grep ‘temporary password’ /var/log/mysqld.log
- 登录:mysql -u root -p
- 修改密码
- 设置策略:
- set global validate_password.policy = 0;
- set global validate_password.length = 6;
- ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
- 创建用户
- 默认的root用户只能当前节点localhost访问,是无法远程访问的,我们还需要创建一个root账户,用户远程访问
- create user ‘root’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
- 分配权限:grant all on . to ‘root’@‘%’;
- 完成,可以通过DataGrip或者Navicat连接了