跳至主要內容

centos7安装mysql5.7

brinishness...小于 1 分钟Mysqlmysqlinstallcentos7

centos7安装mysql5.7

1.下载mysql的yum仓库文件包

yum -y install wget
wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm

2.yum安装mysql

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 # 如果mysql密钥过期了,需要更新一下密钥
yum -y install mysql-community-server

3.启动mysql

systemctl enable mysqld # mysql开机自启
systemctl start mysqld  # 启动mysql
systemctl status mysqld # 查看mysql状态
systemctl restart mysqld # 重启mysql

4.查看mysql密码

cat /var/log/mysqld.log | grep password #首次安装后,可以通过mysql日志查询默认密码

5.修改root密码

mysql -u root -p # 连接数据库,密码为上一步获取到的
set global validate_password_policy=0; # 修改mysql密码策略
set global validate_password_length=1;  # 修改mysql密码长度限制
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; # 修改root密码
FLUSH PRIVILEGES;
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.5