下载官方打包好的rpm的集合

https://downloads.mysql.com/archives/get/file/mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

[root@xuegod63 opt]# tar xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

解压出来,发现有很多rpm包,我们需要用到的包是:

mysql-community-common-5.7.20-1.el7.x86_64.rpm

mysql-community-libs-5.7.20-1.el7.x86_64.rpm

mysql-community-client-5.7.20-1.el7.x86_64.rpm

mysql-community-server-5.7.20-1.el7.x86_64.rpm

依次安装:

yum install mysql-community-common-5.7.20-1.el7.x86_64.rpm -y

yum install mysql-community-libs-5.7.20-1.el7.x86_64.rpm -y

yum install mysql-community-client-5.7.20-1.el7.x86_64.rpm -y

yum install mysql-community-server-5.7.20-1.el7.x86_64.rpm -y

注意安装 mysql-community-server-5.7.20-1.el7.x86_64.rpm报错

[root@b mysql-5.7.26]# yum install mysql-community-server-5.7.26-1.el6.x86_64.rp m -y

Error: Package: mysql-community-server-5.7.26-1.el6.x86_64 (/mysql-community-ser ver-5.7.26-1.el6.x86_64)
Requires: libsasl2.so.2()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

[root@b mysql-5.7.26]# rpm -ivh mysql-community-server-5.7.26-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libsasl2.so.2()(64bit) is needed by mysql-community-server-5.7.26-1.el6.x86_64

原因:这是由于yum安装了旧版本的GPG keys造成的        解决办法: --force --nodeps

[root@b mysql-5.7.26]# rpm -ivh mysql-community-server-5.7.26-1.el6.x86_64.rpm --force --nodeps
warning: mysql-community-server-5.7.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.26-1.e################################# [100%]

(注意:安装顺序不能错,否则会报错依赖包没有安装)

查看安装路径:

[root@xuegod63 opt]# rpm -ql mysql-community-server

可以看到数据库安装在/var/lib/mysql 目录下

启动服务:

[root@xuegod63 opt]# systemctl start mysqld.service

获取临时密码:

第一次通过# grep "password" /var/log/mysqld.log 命令获取MySQL的临时密码

用该密码登录到服务端后,必须马上修改密码,不然操作查询时报错误

[root@xuegod63 opt]# grep "password" /var/log/mysqld.log

2017-11-10T14:38:40.930543Z 1 [Note] A temporary password is generated for root@localhost: itBp#lFva0aY

补充注意:MySQL5.7之前的版权,初次安装MySQL,默认登陆密码是空,5.7之后的版本,默认登陆的密码为一个随机生产的字符串,存在/var/log/mysqld.log 文件里。

 

安全初始化操作:

[root@xuegod65 opt]# mysql_secure_installation

修改默认密码和相关的权限

MySQL5.7对密码复杂度要求比较高,刚开始设置的密码必须符合长度(默认最小长度的8),且必须含有数字,小写或大写字母,特殊字符。

这也是从安全考虑,希望使用者不要强行修改密码策略,设置简单的密码

Welcome1qazx@com

如果想设置简单密码,如下操作:

[root@localhost ~]# mysql -uroot -p' itBp#lFva0aY '

方法一:首先,修改validate_password_policy参数的值

mysql> set global validate_password_policy=0;  #定义复杂度

mysql> set global validate_password_length=1;  #定义长度 默认是8

方法二:在/etc/my.cnf 可关闭密码强度审计插件,重启mysql服务

validate_password=ON/OFF/FORCE/FORCE_PLUS_PERMANENT: 决定是否使用该插件(及强制/永久强制使用)。

修改密码

mysql>

 set password for 'root'@'localhost'=password('123456');    修改root账号登陆密码

Query OK, 0 rows affected, 1 warning (0.05 sec)

刷新权限表(使更改密码立即生效而不用重启mysql)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

登陆linux下的mysql5.7忘记密码

解决方法

  • 第一步:打开mysql5.7的配置文件my.cnf,并在里面增加一行:skip-grant-tables   保存并退出(:wq)
[root@iz09a32x1sghz3z ~]# vi /etc/my.cnf
  • 第二步:重启mysql
[root@iz09a32x1sghz3z ~]# service mysqld restart
  • 第三步:登录mysql并且修改密码

用root账号登录: [root@iz09a32x1sghz3z ~]# mysql -u root

使用mysql中的mysql数据库: mysql> use mysql;

修改密码:  update user set authentication_string = password("Szfore_68638") where user="root" ;

刷新数据库: flush privileges;

退出: quit;

注意:mysql5.7的user表中的password字段已经改成了authentication_string 字段了。

这时候,需要输入的命令是update user set authentication_string = password("Szfore_68638") where user="root" ;

  • 第四步:打开mysql5.7的配置文件my.cnf,把刚增加这行:skip-grant-tables  删除掉 保存并退出(:wq)

Table 2.11 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone

Files or Resources Location
Client programs and scripts /usr/bin
mysqld server /usr/sbin
Configuration file /etc/my.cnf
Data directory /var/lib/mysql
Error log file

For RHEL, Oracle Linux, CentOS or Fedora platforms:/var/log/mysqld.log

For SLES: /var/log/mysql/mysqld.log

Value of secure_file_priv /var/lib/mysql-files
System V init script

For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld

For SLES: /etc/init.d/mysql

Systemd service

For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld

For SLES: mysql

Pid file /var/run/mysql/mysqld.pid
Socket /var/lib/mysql/mysql.sock
Keyring directory /var/lib/mysql-keyring
Unix manual pages /usr/share/man
Include (header) files /usr/include/mysql
Libraries /usr/lib/mysql
Miscellaneous support files (for example, error messages, and character set files) /usr/share/mysql
  • RHEL, Oracle Linux, CentOS, and Fedora systems:

    shell> sudo grep 'temporary password' /var/log/mysqld.log

    The next step is to log in with the generated, temporary password and set a custom password for the superuser account:

shell> mysql -uroot -p
 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

二进制方式安装mysql的更多相关文章

  1. Linux下通用二进制方式安装MySQL

    1.下载glibc版本的MySQL: https://downloads.mysql.com/archives/community/ 2.查看mysql用户和mysql组是否存在(用户和组的信息存在/ ...

  2. MAC使用二进制方式安装Mysql 5.7

    一.参考文档: 二.基础环境: 系统:Centos7.4 mysql版本:percona mysql 5.7 三.部署mysql 1.初始化 mysqld --initialize --explici ...

  3. 2-14 MySQL初步认识,及CentOS6.8环境,源码方式安装MySQL

    什么是数据库: 存放数据的仓库RDBMS-->(Relational Database Management System) 关系型数据库管理系统DBMS--->(Database Man ...

  4. CentOS 6 自定义单实例 二进制方式 安装mariadb-5.5.59

    系统平台: CentOS release 6.9 (Final) 内核 2.6.32-696.el6.x86_64 1.去官网下载适合的二进制包 http://mariadb.org/ mariadb ...

  5. 二进制包安装MySQL数据库

    1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 [ ...

  6. CentOS 6.5 RPM包方式安装 Mysql 5.6

    1. 下载MySQL 5.6 下载页面:http://dev.mysql.com/downloads/mysql/此处选择“Red Hat Enterprise Linux 6 / Oracle Li ...

  7. 在centos使用rpm包的方式安装mysql,以及更改root密码

    在centos使用rpm包的方式安装mysql,对于centos官方实际推荐使用yum进行安装,下载安装的方式主要用于内网服务器不能连接外网yum源的情况. 下载包 首先根据centos版本在mysq ...

  8. CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]

    一 CentOS下通过rpm方式安装MySQL CentOS版本:CentOS-7 MySQL版本:MySQL-5.6.22 在网上搜了一下,Linux下安装MYSQL有三种方式: 1) 通过yum命 ...

  9. CentOS 6.5通过yum的方式安装MySql

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

随机推荐

  1. win10 powershell禁止运行脚本解决

    win10 现在默认策略为 Restricted 该策略情况下是禁止在终端下运行脚本文件的,所以我们想要通过powershell 来运行我们的脚本文件的话就需要我们更改其策略才行,如下命令可以帮助你 ...

  2. 简述在Ubuntu终端打开文件的几种不同方法与区别

    一· 在Ubuntu下,通常用命令行打开文本文件,比如用命令gedit.more.cat.vim.less. gedit:在文本软件下打开文件,可直接修改. more ,cat 和 less :类似, ...

  3. 字符串的 Base64 加密和解密

    base64加密: FORM encode_base64 USING p_business “字符串string CHANGING p_base64. DATA l_xstring TYPE xstr ...

  4. Maven项目构建利器04——Maven的一些核心概念

    1.坐标 1)数学上的坐标: [1].在平面上. 使用X,Y两个向量可以唯一的定位平面上的任意一个点 [2]在空间中, 使用X,Y,Z三个向量可以唯一的定位空间中的任何一个点 2)Maven中的坐标: ...

  5. Python控制语句执行流程

    if语句: if<条件>:#条件之后必须有“:”.  <语句> if语句的三元运算符: <表达式1>if<条件>else<表达式2>:其语义 ...

  6. tomcat同个端口配置多个项目后无后缀的页面跳转

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  7. Python核心技术与实战——十四|Python中装饰器的使用

    我在以前的帖子里讲了装饰器的用法,这里我们来具体讲一讲Python中的装饰器,这里,我们从前面讲的函数,闭包为切入点,引出装饰器的概念.表达和基本使用方法.其次,我们结合一些实际工程中的例子,以便能再 ...

  8. springboot 关于log4j日志配置

    自动加载配置文件:(1)如果采用log4j输出日志,要对log4j加载配置文件的过程有所了解.log4j启动时,默认会寻找source folder下的log4j.xml配置文件,若没有,会寻找log ...

  9. Python 3标准库课件第一章(第二版)

    第一章文本1.1 string:文本常量和模板1.2 textwrap:格式化文本段落1.3 re:正则表达式1.4  difflib:比较序列str类,string.Templatetextwrap ...

  10. antd不可选择时间

    //不能选择今天之前的日期<DatePicker format={this.timeFormat} showTime placeholder="项目结束日期" disable ...