1.使用root用户登录
2.卸载mariadb
rpm -qa|grep mariadb #查看
yum remove mariadb-libs-1:5.5.56-2.el7.x86_64 #卸载
4.安装数据库
rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
5.启动mysql
service mysqld status #查看mysql启动状态
service mysqld start #启动mysql
6.登录修改密码
grep password /var/log/mysqld.log #查看密码
mysql -uroot -pXXXXXX #登录
set global validate_password_policy=0; #设置密码安全策略为LOW
set global validate_password_length=4; #设置密码长度最小为4
set password=password('root'); #设置密码
7.赋予权限(root 权限根据情况赋予)
grant all privileges on *.* to 'root'@'%' identified by 'xxxxx'(密码) with grant option;
8.修改配置文件
vi /etc/my.cnf #辑my.cnf文件,在[mysqld]中增加两行,
lower_case_table_names=1 #配置表名不区分大小写 1:不区分大小写 0:区分大小写 这行必须配置 默认表名是区分大小写的,不利于开发
skip-name-resolve(禁止域名解析)
9.重启mysql
service mysqld restart
10.关闭防火墙
systemctl stop firewalld.service #关闭
systemctl disable firewalld.service #禁用开机自启
centos7安装mysql5.7
最新推荐文章于 2024-05-31 10:20:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)