CentOS7下安装MySQL5.7

  1. 安装YUM repo
    由于centos的yum源中没有MySQL,需要到MySQL官网下载yum repo的配置文件
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

然后进行repo的安装

[root@wg001 ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm 
警告:mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql57-community-release-el7-9  ################################# [100%]
[root@wg001 ~]# 

# yum makecache

之后就可以用yum进行安装了
在安装之前需要把之前的MySQL删掉: 使用

rpm -qa |grep mysql

发现有输出结果,依次删除

rpm -e **** --nodeps

开始安装MySQL

#yum install mysql-community-server

安装时间有点长,在十分钟左右。

启动MySQL

[root@wg001 ~]# systemctl start mysqld

配置MySQL,获取MySQL的临时密码

[root@wg001 ~]# grep  'temporary password' /var/log/mysqld.log 
2018-12-02T14:08:10.483897Z 1 [Note] A temporary password is generated for root@localhost: e%3t6nfd.vrK

登陆数据库

[root@wg001 ~]# mysql -uroot -pe%3t6nfd.vrK
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

可以看到版本号是5.7.24
登陆后需要及时修改密码

mysql> set password=password("ZMedu118118!");
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on  *.* to root@"%" identified by "ZMedu118118!";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges 

注意: 密码不能设置的过于简单,如果太简单会报错。
设置安全选项

# mysql_secure_installation

默认配置文件

配置文件:/etc/my.cnf 
日志文件:/var/log//var/log/mysqld.log 
服务启动脚本:/usr/lib/systemd/system/mysqld.service 
socket文件:/var/run/mysqld/mysqld.pid
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值