centos7使用rpm安装mysq5.7

打开清华大学开源软件镜像站

https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/

本次以5.7.16 为例

下载安装包,一共4个包

wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-server-5.7.16-1.el7.x86_64.rpm    --no-check-certificate
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-common-5.7.16-1.el7.x86_64.rpm    --no-check-certificate 
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-libs-5.7.16-1.el7.x86_64.rpm      --no-check-certificate 
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-client-5.7.16-1.el7.x86_64.rpm    --no-check-certificate

安装,注意先后顺序

1. yum  localinstall   mysql-community-common-5.7.16-1.el7.x86_64.rpm  -y
3. yum  localinstall   mysql-community-client-5.7.16-1.el7.x86_64.rpm  -y
2. yum  localinstall   mysql-community-libs-5.7.16-1.el7.x86_64.rpm  -y
4. yum  localinstall   mysql-community-server-5.7.16-1.el7.x86_64.rpm  -y

启动

systemctl  start  mysqld
systemctl  enable  mysqld

查看初始密码

[root@localhost mysql]# cat  /var/log/mysqld.log  | grep -i 'password'
2023-04-13T07:26:28.482386Z 1 [Note] A temporary password is generated for root@localhost: gWu!4Uz38,iQ  这个就是初始密码

登录数据库【用上一步查到的密码进行登录】

mysql  -uroot  -p   

修改密码

set password = "Qihaitest2023!";

set  password for 'root'@'localhost'  = password("Qihaitest2023!");

然后再使用新密码登录即可。

修改数据目录

vim  /etc/my.cnf

 

datadir=/data/mysql    # 这里改成自己的目录即可。

 

然后重启。如果重启失败,看下是不是selinux的问题。如果selinux是开启状态,将selinux关闭即可。然后重启。

 

posted @ 2023-04-13 15:39  羊脂玉净瓶  阅读(21)  评论(0)    收藏  举报