1.安装
1.配置yum仓库
#更换密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
#安装mysql yum库
rpm -Uvh https://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
2.使用yum安装mysql
yum -y install mysql-community-server
3.启动MySQL服务并设置开机自启
#启动
sudo systemctl start mysqld
#开机自启
sudo systemctl enable mysqld
4.安装完成后,您可以使用以下命令检查MySQL服务状态
sudo systemctl status mysqld
5.查看Mysql的初始密码密码
sudo grep 'temporary password' /var/log/mysqld.log
6.登录MySQL 5.7
mysql -u 用户名 -p #注意空格
7.然后进入MySQL 5.7后修改自己记得住的密码
#密码得8个字符或更多、包含字母、数字和特殊字符的密码
ALTER USER '用户名'@'localhost' IDENTIFIED BY '新密码';
#当然如果你想降低密码难度可以先输入
SET GLOBAL validate_password_policy=LOW;
和
SET GLOBAL validate_password_length=4;
(这个可写可不写)配置root远程登录
#你可以暴力一点,让所有IP都可以登录的话就把ip地址改成%,密码要设一个新的,可以随意
grant all privileges on *.* to root@"ip地址" identified by '密码' with grant option;
#刷新权限
flush privileges;
8.查询端口
netstat -anp | grep 3306