mysql5.7安装

1、下载rpm包

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar

# 如果提示需要账号密码,就用这个方式下载
# wget --http-user=youremail@email.com --http-passwd=yourpassword https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar

2、看系统是否自带mariadb

rpm -qa | grep mariadb

3、将查出的mariadb进行卸载

rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64

4、把刚刚下载的mysql tar解压

tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar

5、在解压目录安装如下4个mysql核心包

rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm

6、如果安装到server时报错,缺少依赖

error: Failed dependencies: libaio.so.1()(64bit) is needed by mysql-community-server-5.7.28-1.el7.x86_64
       libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.28-1.el7.x86_64
        libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.28-1.el7.x86_64

7、安装缺少的依赖

yum -y install libaio

8、再次安装server

rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm

9、启动mysql服务

systemctl start mysqld

10、查看v5.7版本的默认登录密码

grep password /var/log/mysqld.log
登录: mysql -u root -p

11、登录到mysql命令行,修改默认密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

12、会告诉你密码不符合规范,可以修改校验等级和长度后再次执行上面的语句

set global validate_password_policy=LOW;
set global validate_password_length=6;

13、账户授权

use mysql;
select host,user from user;
# 所有ip都可以访问数据库
grant all privileges on *.* to gavin@'%' identified by '123456';
# 只有内网网段ip才可访问,并授权账号可以授权其他人
# grant all privileges on *.* to gavin@'192.168.%' identified by '123456' with grant option;
flush privileges;

 

posted @ 2020-06-22 16:10  alenblue\own  阅读(298)  评论(0编辑  收藏  举报