home目录下新建安装包存放位置
cd home mkdir install_packet cd /home/install_packet
下载mysql5.7 rpm源
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
安装下载好的rpm包
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
安装mysql
yum install -y mysql-server
有可能会提示:mysql-community-client-5.7.39-1.el7.x86_64.rpm 的公钥尚未安装 可能是MySQL GPG 密钥已过期导致,改一下密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
运行mysql
service mysqld start
取得mysql初始化随机密码
grep "password" /var/log/mysqld.log
登录mysql
mysql -u root -p
输入刚刚命令打印的密码 root@localhost: xxxxxxx
更改root密码,需要带数字,大写字母,小写字母,特殊符号
SET PASSWORD = PASSWORD('你的新密码'); # 上面的方式不行就用下面这个 ALTER USER USER() IDENTIFIED BY '你的新密码'; # 设置密码永不过期 ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; # 刷新MySQL的系统权限相关表 flush privileges;
设置数据库用户在所有ip下以及在本地可访问,以下用root用户做演示
grant all privileges on *.* to root@"%" identified by "你的密码"; grant all privileges on *.* to root@"localhost" identified by "你的密码"; flush privileges;
exit;
防火墙设置
firewall-cmd --zone=public --add-port=3306/tcp --permanent
标签:--,rpm,privileges,mysql,centos7,密码,linux,root From: https://www.cnblogs.com/void--main/p/17771698.html