安装mysql
下载rpm包
wget -c https://repo.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
解压
tar xf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
卸载mariadb-libs
yum remove mariadb-libs
如果没有net-tools需要先安装
yum install net-tools -y
安装解压出来的rpm包
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm mysql-community-common-5.7.37-1.el7.x86_64.rpm mysql-community-libs-5.7.37-1.el7.x86_64.rpm mysql-community-server-5.7.37-1.el7.x86_64.rpm
安装完后,启动
systemctl start mysqld
登录并修改密码
P=`awk '/temporary password/ {print $NF}' /var/log/mysqld.log`
mysql -uroot -p$P
alter user 'root'@'%' identified by 'MySQL@2023'; ##%代表任意ip可连接