YUM安装5.7版本mysql

本文介绍了如何在CentOS 7.4系统上通过YUM安装MySQL 5.7,包括关闭防火墙和SELINUX、配置yum源、安装数据库、设置开机启动、修改初始密码以及理解MySQL相关文件路径。
摘要由CSDN通过智能技术生成

环境:

系统版本:CentOS Linux release 7.4.1708 (Core)

内核:Linux 3.10.0-693.el7.x86_64

                              **YUM安装mysql**

1、yum安装方式

关闭防火墙和selinux

[root@mysql-server ~]# systemctl stop firewalld

[root@mysql-server ~]# systemctl disable firewalld

永久关闭SELINUX的方式如下:

[root@mysql-server ~]# vim /etc/selinux/config
把SELINUX设置成永久关闭SELINUX=disabled

下边给出mysql的官网下载方式

在这里插入图片描述

拉到底

在这里插入图片描述
4
5
在这里插入图片描述
在这里插入图片描述

下载

[root@mysql-server ~]# yum -y install wget

[root@mysql-server ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

或者下载到本地上传到服务器

2.安装mysql的yum仓库

[root@mysql-server ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm

[root@mysql-server ~]# yum -y install yum-utils #安装yum工具包

3、配置yum源

[root@mysql-server ~]# vim /etc/yum.repos.d/mysql-community.repo #修改如下
在这里插入图片描述

1表示开启,0表示关闭

或者

# yum-config-manager --enable mysql57-community 将禁用的yum源库启用

# yum-config-manager --disable mysql80-community 将启用的yum源库禁用

4、安装数据库

[root@mysql-server ~]# yum install -y mysql-community-server

启动服务

[root@mysql-server ~]# systemctl start mysqld

设置开机启动

[root@mysql-server ~]# systemctl enable mysqld

5、查找密码

密码保存在日志文件中

[root@mysql-server ~]# grep password /var/log/mysqld.log

2019-08-18T14:03:51.991454Z 1 [Note] A temporary password is generated for root@localhost: woHtkMgau9,w

6、修改密码

[root@mysql-server ~]# mysql -uroot -p'woHtkMgau9,w' #登录

两种方式:

第一种:

mysql> alter user 'root'@'localhost' identified by 'Zw@123';

[root@mysql-server ~]# mysql -uroot -p'woHtkMgau9,w'

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.27

mysql> alter user 'root'@'localhost' identified by 'Zw@123';

Query OK, 0 rows affected (0.01 sec)

mysql> exit

Bye

[root@mysql-server ~]# mysql -uroot -p'Zw@123'

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 3

Server version: 5.7.27 MySQL Community Server (GPL)

mysql> exit

Bye

第二种:

# mysqladmin -u root -p'旧密码' password '新密码'

注:修改密码必须大小写数字和特殊符号都有。

通过配置文件设置密码强度

[root@mysql-server ~]# vim /etc/my.cnf #在最后添加如下内容

validate_password=off

[root@mysql-server ~]# systemctl restart mysqld #重启mysql生效

可以用第二种方式修改为简单的密码:

[root@mysql-server ~]# mysqladmin -uroot -p'Zw@123' password 'Zw123'

mysqladmin: [Warning] Using a password on the command line interface can be insecure.

Warning: Since password will be sent to server in plain text, use ssl connection to ensure

password safety.

[root@mysql-server ~]# mysql -uroot -p'Zw@123'

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 3

Server version: 5.7.27 MySQL Community Server (GPL)

Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> exit

Bye

下面是对mysql的一些文件进行说明

/var/lib/mysql 存放数据文件

/usr/share/mysql 用于存放字符集、语言等信息等消息。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值