1.查看防火墙状态
systemctl status firewalld.service
2.建议永久关闭防火墙状态
systemctl disable firewalld.service
3.编辑配置文件
vim /etc/yum.repos.d/mysql.repo
4.将这四行代码粘贴到配置文件中
[mysql]
name=mysql5.7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/
gpgcheck=0
5.安装数据库
yum -y install mysql-community-server
6.启动数据库
systemctl enable --now mysqld
7.查看端口号,看是否有3366端口号
ss -ntl
8.启动进入mysql
mysql
9.查看数据库默认密码
grep password /var/log/mysqld.log
10.登录MySQL
mysql -uroot -p'log里面的默认密码'
11.重新设置密码
alter user root@'localhost' identified by '想设置的密码';
12.让本地远程数据库软件能连接到
grant all privileges on *.* to 'root'@'%' identified by '远程连接密码,建议和数据库设置为一样,防止忘记' with grant option;