centos 安装MySQL

1.运行以下命令更新YUM源

rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.运行以下命令安装MySQL

如果您使用的操作系统内核版本为el8,可能会提示报错信息No match for argument。您需要先运行命令yum module disable mysql禁用默认的MySQL模块,再安装MySQL。

yum -y install mysql-community-server --nogpgcheck

3.运行以下命令查看MySQL版本号

mysql -V

返回结果如下所示,表示MySQL安装成功。
mysql Ver 14.14 Distrib 5.7.36, for Linux (x86_64) using EditLine wrapper

4.运行以下命令启动MySQL

systemctl start mysqld

5.依次运行以下命令设置开机启动MySQL

systemctl enable mysqld
systemctl daemon-reload

6.运行以下命令查看/var/log/mysqld.log文件,获取并记录root用户的初始密码

grep 'temporary password' /var/log/mysqld.log

出现下面内容

2022-12-20T19:42:35.250992Z 1 [Note] A temporary password is generated for root@localhost: _N!G-o8LFv=d

7.运行以下命令配置MySQL的安全性。

mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root: #输入上一步获取的root用户初始密码
The existing password for the user account root has expired. Please set a new password.

New password: #输入新密码。长度为830个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号包含()` ~!@#$%^&*-+=|{}[]:;<>,.?/

Re-enter new password: #确认新密码。
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 #返回结果包含您设置的密码强度。
Change the password for root ? ((Press y|Y for Yes, any other key for No) :Y #您需要输入Y以确认使用新密码。

#新密码设置完成后,需要再次验证新密码。
New password:#再次输入新密码。

Re-enter new password:#再次确认新密码。

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :Y #您需要输入Y,再次确认使用新密码。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值