由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
然后进行repo的安装:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo
安装mysql
yum install mysql-server
启动mysql
systemctl start mysqld
查看临时密码
grep 'temporary password' /var/log/mysqld.log
使用临时密码登录
但是修改密码出现问题
密码策略修改
set global validate_password_policy=0; set global validate_password_length=1;
修改密码
alter user 'root'@'localhost' identified by '12345678';
授权远程访问
grant all privileges on *.* to 'root'@'%' identified by '12345678' with grant option;