MySQL 8.0
centos7.5 x86_64
一.yum安装
1.先卸载机器和mysql有关的东西,有的安装了mariab-lib,会对安装有干扰,卸载了它。
  1. [root@localhost ~]# rpm -qa | grep mariadb
  1. mariadb-libs-5.5.60-1.el7_5.x86_64
2.卸载命令
  1. yum erase -y mariadb-libs-5.5.60-1.el7_5.x86_64
二.安装mysql 8.0 社区版yum仓库
1.官方网站
2.下载仓库包
  1. wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
3.安装仓库
  1. rpm -ivh mysql80-community-release-el7-1.noarch.rpm
4.安装mysql 8.0版
  1. yum install -y mysql-community-{server,client,common,libs}-*
5.启动mysql 8.0
  1. systemctl start mysqld
  1. systemctl enable mysqld
6.查看日志,找到临时密码,这里还一个问题,日志这个时间不正确,与本地差好几个小时呢 ,这个在安装完了,再调下。
  1. [root@localhost ~]# tailf /var/log/mysqld.log
  1. 2019-01-12T13:59:34.558708Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 7038
  1. 2019-01-12T13:59:36.873412Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: :ZSytWyMp6Q>
  1. 2019-01-12T13:59:38.113827Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server has completed
  1. 2019-01-12T13:59:39.798256Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.13) starting as process 7085
  1. 2019-01-12T13:59:40.949981Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  1. 2019-01-12T13:59:41.019836Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.13' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
  1. 2019-01-12T13:59:41.190008Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
这个就启动了 第二行 最后那个就是密码
7.登录
把那个临时密码输入进去,就可以登录了
  1. [root@localhost ~]# mysql -u root -p
  1. Enter password:
  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  1. Your MySQL connection id is 12
  1. Server version: 8.0.13
  1.  
  1. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  1.  
  1. Oracle is a registered trademark of Oracle Corporation and/or its
  1. affiliates. Other names may be trademarks of their respective
  1. owners.
  1.  
  1. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  1.  
  1. mysql>
8.修改临时密码
跟之前的版本不一样,得把临时密码给改了,之前set password=password('mima') 这个命令已经不好使了
  1. mysql> show databases;
  1. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  1. mysql>
yum 安装还有一个问题,就是密码还有复杂性要求,这东西策略我还不知道怎么改
  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'dgdb20I5';
  1. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'dgdB20I5!@#';
  1. Query OK, 0 rows affected (0.02 sec)
  1.  
  1. mysql>
用新密码重新登录就行了
9.修改日志时间问题
  1. mysql> select now();
  1. +---------------------+
  1. | now() |
  1. +---------------------+
  1. | 2019-01-12 22:22:19 |
  1. +---------------------+
  1. 1 row in set (0.00 sec)
  1.  
  1. mysql> SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
  1. +----------------+-------+
  1. | Variable_name | Value |
  1. +----------------+-------+
  1. | log_timestamps | UTC |
  1. +----------------+-------+
  1. 1 row in set (0.00 sec)
  1.  
  1. mysql> SET GLOBAL log_timestamps = SYSTEM;
  1. Query OK, 0 rows affected (0.00 sec)
  1.  
  1. mysql> SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
  1. +----------------+--------+
  1. | Variable_name | Value |
  1. +----------------+--------+
  1. | log_timestamps | SYSTEM |
  1. +----------------+--------+
  1. 1 row in set (0.00 sec)
  1.  
  1. mysql> exit
且默认安装后error_log,slow_log 日志时间戳默认为UTC,因此会造成与系统时间不一致,与北京时间相差8个小时
因为log_timestamps 是一个GLOBAL的全局参数,所以直接在登录后去set全局参数,重启后就会直接失效
因此需要在mysql的配置文件中[mysqld]中增加一条log_timestamps的配置
  1. vim /etc/my.cnf
  1. [mysqld]
  1.  
  1. log_timestamps=SYSTEM
重启下MySQL
  1. systemctl restart mysqld
再查看下日志,果然时间就对了
  1. [root@localhost ~]# tailf /var/log/mysqld.log
  1. 2019-01-12T13:59:38.113827Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server has completed
  1. 2019-01-12T13:59:39.798256Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.13) starting as process 7085
  1. 2019-01-12T13:59:40.949981Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  1. 2019-01-12T13:59:41.019836Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.13' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
  1. 2019-01-12T13:59:41.190008Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
  1. 2019-01-12T22:29:25.655750+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.13) MySQL Community Server - GPL.
  1. 2019-01-12T22:29:26.338014+08:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.13) starting as process 24698
  1. 2019-01-12T22:29:26.856796+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  1. 2019-01-12T22:29:26.878264+08:00 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.13' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
  1. 2019-01-12T22:29:27.007610+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
10.修改MySQL数据目录位置
a.查询MySQL 8.0默认数据目录
  1. mysql> show variables like '%dir%';
  1. +-----------------------------------------+--------------------------------+
  1. | Variable_name | Value |
  1. +-----------------------------------------+--------------------------------+
  1. | basedir | /usr/ |
  1. | binlog_direct_non_transactional_updates | OFF |
  1. | character_sets_dir | /usr/share/mysql-8.0/charsets/ |
  1. | datadir | /var/lib/mysql/ |
  1. | innodb_data_home_dir | |
  1. | innodb_directories | |
  1. | innodb_log_group_home_dir | ./ |
  1. | innodb_max_dirty_pages_pct | 90.000000 |
  1. | innodb_max_dirty_pages_pct_lwm | 10.000000 |
  1. | innodb_temp_tablespaces_dir | ./#innodb_temp/ |
  1. | innodb_tmpdir | |
  1. | innodb_undo_directory | ./ |
  1. | lc_messages_dir | /usr/share/mysql-8.0/ |
  1. | plugin_dir | /usr/lib64/mysql/plugin/ |
  1. | slave_load_tmpdir | /tmp |
  1. | tmpdir | /tmp |
  1. +-----------------------------------------+--------------------------------+
  1. 16 rows in set (0.00 sec)
显而易见,datadir在 /var/lib/myql
b.先把MySQL停下来
  1. systemctl stop mysqld
c.创建数据目录,复制数据文件(加入我把数据目录放到/home/下)
  1. mkdir /home/mysql_data
  1. cp -r /var/lib/mysql/* /home/mysql_data/
  1. chown -R mysql:mysql /home/mysql_data
c.编辑配置文件
  1. vim /etc/my.cnf
  1. datadir=/home/mysql_data
  1. socket=/home/mysql_data/mysql.sock
  1. #下面这得加上,不然服务能起来,你客户端不能登录
  1. [mysql]
  1. socket=/home/mysql_data/mysql.sock
d.启动并查询
  1. systemctl start mysqld
  1. [root@localhost my.cnf.d]# mysql -u root -p
  1. Enter password:
  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  1. Your MySQL connection id is 8
  1. Server version: 8.0.13 MySQL Community Server - GPL
  1.  
  1. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  1.  
  1. Oracle is a registered trademark of Oracle Corporation and/or its
  1. affiliates. Other names may be trademarks of their respective
  1. owners.
  1.  
  1. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  1.  
  1. mysql> show variables like '%dir%';
  1. +-----------------------------------------+--------------------------------+
  1. | Variable_name | Value |
  1. +-----------------------------------------+--------------------------------+
  1. | basedir | /usr/ |
  1. | binlog_direct_non_transactional_updates | OFF |
  1. | character_sets_dir | /usr/share/mysql-8.0/charsets/ |
  1. | datadir | /home/mysql_data/ |
  1. | innodb_data_home_dir | |
  1. | innodb_directories | |
  1. | innodb_log_group_home_dir | ./ |
  1. | innodb_max_dirty_pages_pct | 90.000000 |
  1. | innodb_max_dirty_pages_pct_lwm | 10.000000 |
  1. | innodb_temp_tablespaces_dir | ./#innodb_temp/ |
  1. | innodb_tmpdir | |
  1. | innodb_undo_directory | ./ |
  1. | lc_messages_dir | /usr/share/mysql-8.0/ |
  1. | plugin_dir | /usr/lib64/mysql/plugin/ |
  1. | slave_load_tmpdir | /tmp |
  1. | tmpdir | /tmp |
  1. +-----------------------------------------+--------------------------------+
  1. 16 rows in set (0.01 sec)
11.mysql免密码登录
直接在[mysql]下面添加root password就行了
  1. vim /etc/my.cnf
  1. [mysql]
  1. user='root'
  1. password='dgdB20I5!@#'
下次直接输入mysql就可以登录了,方便的很,生产环境谨慎使用
  1. [root@localhost ~]# mysql
  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  1. Your MySQL connection id is 12
  1. Server version: 8.0.13 MySQL Community Server - GPL
  1.  
  1. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  1.  
  1. Oracle is a registered trademark of Oracle Corporation and/or its
  1. affiliates. Other names may be trademarks of their respective
  1. owners.
  1.  
  1. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  1.  
  1. mysql> exit
  1. Bye
12.配置MySQL远程连接配置
  1. [root@localhost ~]# mysql
  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  1. Your MySQL connection id is 15
  1. Server version: 8.0.13 MySQL Community Server - GPL
  1.  
  1. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  1.  
  1. Oracle is a registered trademark of Oracle Corporation and/or its
  1. affiliates. Other names may be trademarks of their respective
  1. owners.
  1.  
  1. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  1.  
  1.  
  1. mysql> use mysql;
  1. Reading table information for completion of table and column names
  1. You can turn off this feature to get a quicker startup with -A
  1.  
  1. Database changed
  1. mysql> select host, user, authentication_string, plugin from user;
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. | host | user | authentication_string | plugin |
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | root | $A$005$LP^CZmMk
  1. T4'S0<PcRj0oL/YI9p7IGi1Q59wifPwX/93nRiZez4GboEPK/ | caching_sha2_password |
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. 4 rows in set (0.00 sec)
  1.  
  1. mysql>
这里看到都是localhost,所以还不能远程连接
root账户为默认的密码加密方式是:caching_sha2_password;而现在很多客户端工具还不支持这种加密认证方式,连接测试的时候就会报错:client does not support authentication protocol requested by server; consider upgrading MySQL client,这里的错误信息就是不支持身份认证方式 新创建的用户有效,老用户还是不行的
所以,我们需要修改下配置文件,修改下默认加密方式,在[mysqld]下面添加一行default-authentication-plugin=mysql_native_password
  1. vim /etc/my.cnf
  1. [mysqld]
  1. default-authentication-plugin=mysql_native_password
重启MySQL
  1. systemctl restart mysqld
修改用户远程访问权限
  1. mysql> grant all on *.* to 'root'@'%' identified by 'Zhang87073!';
  1. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Zhang87073!'' at line 1
MySQL 8.0 这里报错了。。。之前的版本都是这样一行就搞定了 。。。所以 。。。
  1. #这里先创建一个用户
  1. mysql> create user 'root'@'%' identified by 'Zhang87073!';
  1. Query OK, 0 rows affected (0.06 sec)
  1. #在进行授权
  1. mysql> grant all privileges on *.* to 'root'@'%' with grant option;
  1. Query OK, 0 rows affected (0.05 sec)
  1. #再查看一下
  1. mysql> use mysql;
  1. Reading table information for completion of table and column names
  1. You can turn off this feature to get a quicker startup with -A
  1.  
  1. Database changed
  1. mysql> select host, user, authentication_string, plugin from user;
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. | host | user | authentication_string | plugin |
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. | % | root | *43CAAB27D90B4E33EC75DEEFA02577F7E2BACE93 | mysql_native_password |
  1. | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
  1. | localhost | root | $A$005$LP^CZmMk
  1. T4'S0<PcRj0oL/YI9p7IGi1Q59wifPwX/93nRiZez4GboEPK/ | caching_sha2_password |
  1. +-----------+------------------+------------------------------------------------------------------------+-----------------------+
  1. 5 rows in set (0.00 sec)
远程连接测试
 
13.修改密码策略
yum 安装的时候 遇到了密码策略的问题,我查询了一下,现在得到了答案,且发现二进制包安装完,这个密码策略是空的。
a.查看当前的密码策略
  1. mysql> SHOW VARIABLES LIKE 'validate_password%';
  1. +--------------------------------------+--------+
  1. | Variable_name | Value |
  1. +--------------------------------------+--------+
  1. | validate_password.check_user_name | ON |
  1. | validate_password.dictionary_file | |
  1. | validate_password.length | 8 |
  1. | validate_password.mixed_case_count | 1 |
  1. | validate_password.number_count | 1 |
  1. | validate_password.policy | MEDIUM |
  1. | validate_password.special_char_count | 1 |
  1. +--------------------------------------+--------+
  1. 7 rows in set (0.00 sec)
b.密码策略的解释
validate_password.check_user_name 这个参数用来检查用户名
validate_password_dictionary_file 字典文件
validate_password_length密码长度的最小值(这个值最小要是4)。
validate_password_mixed_case_count大小写的最少个数
validate_password_number_count 密码中数字的最少个数
validate_password_policy 这个参数用于控制validate_password的验证策略 0-->low 1-->MEDIUM 2-->strong。
validate_password_special_char_count 特殊字符的最小个数
c.修改密码策略
举个例子 知道怎么搞就行了 (我觉得这东西还是复杂点没坏处)
  1. mysql > set global validate_password.policy=0;
  1. mysql > set global validate_password.policy=0;
  1. mysql > set global validate_password.length=4;
  1. mysql > set global validate_password.check_user_name=OFF;
  1. mysql > set global validate_password.number_count=0;
  1. mysql > set global validate_password.special_char_count=0;
  1. mysql > flush privileges;
  1. mysql > ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root' ;
  1. mysql > update user set host='%' where user ='root';
OK了 就写这么多吧。MySQL 8.0我也是第一次用

MySQL 8.0 yum安装和配置的更多相关文章

  1. Linux下的 Mysql 8.0 yum 安装 并修改密码

    1.MySQL版本: mysql> select @@version;+-----------+| @@version |+-----------+| 8.0.18 |+-----------+ ...

  2. MySql 8.0.12安装、配置

    1. 参考:① 菜鸟教程下载安装MySQl ② 8.0.12安装方法 以下是我遇到的问题: 2.执行 mysqd --initialize --console 后,这个时候运行突然报"无法启 ...

  3. mysql 5.0.46安装配置

    http://os.chinaunix.net/a2008/0801/986/000000986346.shtml RPM包和源码包存放位置 /usr/local/src 源码包编译安装位置(pref ...

  4. MySQL数据库服务器(YUM)安装

    1. 概述2. 部署过程2.1 虚拟机console的NFS服务端配置2.2 虚拟机node15的NFS客户端配置2.3 虚拟机安装MySQL环境2.4 配置MySQL3. 错误及解决3.1 启动失败 ...

  5. centos7.0 yum 安装php服务器

    https://blog.csdn.net/jiaoshenmo/article/details/50923900 首先收一下:centos7.0用yum直接安装apache.php他们的默认版本是a ...

  6. centos7安装MongoDB4.0(yum安装)

    1.添加 yum repo vi /etc/yum.repos.d/mongodb-org-4.0.repo 添加如下内容 [mongodb-org-4.0] name=MongoDB Reposit ...

  7. MySQL 8.0.20 安装教程图文详解(windows 64位)

    MySQL 8.0.20 安装教程图文详解(windows 64位)  更新时间:2020年05月09日 15:09:04   转载 作者:瘦肉粥不加糖     这篇文章主要介绍了MySQL 8.0. ...

  8. Centos 升级MySQL版本或者Yum安装Mysql5.6

    Centos 升级MySQL版本或者Yum安装Mysql5.6 1.从MySQL Yum仓库下载最新的rpm文件:http://dev.mysql.com/downloads/repo/yum/Cen ...

  9. win10下MYSQL的下载、安装以及配置超详解教程(转)

    下载MYSQL 官网下载MYSQL5.7.21版本,链接地址https://www.mysql.com/downloads/.下载流程图如下: 进入官网点击Community,下载社区版. 找到MYS ...

随机推荐

  1. Postman学习宝典(二)

    文章来源于:米阳MeYoung Postman 入门2 - Script.Runner 上次Postman 入门1 我们介绍全局变量和环境变量时已经使用过Tests 和 pre-request scr ...

  2. python实现摇骰子猜大小函数升级没把加注及三大运行商短信验证过滤

    摇骰子游戏升级 此次更改增加下注功能,启动资金1000元,每次赔率都是一倍,钱输光退出. 源码: #!/user/bin/env python #-*-coding:utf-8 -*- #Author ...

  3. java中字符串截取

    1.使用StringUtils,需要导包 String strs = "abcdef1003535197"; System.out.println("=====2==== ...

  4. OGG FOR BigData(Hive) GoldenGate 性能测试

    版本信息: Oracle GoldenGate Command Interpreter Version 12.2.0.1.160419 OGGCORE_12.2.0.1.0OGGBP_PLATFORM ...

  5. Node.js服务器创建和使用

    1.使用zlib模块对服务器端响应压缩 //1.1引入zlib模块 const zlib=require('zlib'); //1.2 设置内容的压缩形式 'Content-Encoding': 'g ...

  6. MySQL索引及优化(1)存储引擎和底层数据结构

    在昨天的面试中问到了MySQL索引怎么优化(查询很慢怎么办),回答的很不理想,所以今天来总结几篇关于MySQL索引的知识. 1.什么是索引? 首先我们一定要明确什么是索引?我自己的总结就是索引是一种数 ...

  7. select 下拉框样式修改 option文字居右

    select { direction: rtl; /*Chrome和Firefox里面的边框是不一样的,所以复写了一下*/ border: solid 1px #000; /*很关键:将默认的sele ...

  8. Oracle操作时间-----摘抄而来

    1.日期时间间隔操作  当前时间减去7分钟的时间  select sysdate,sysdate - interval ’7’ MINUTE from dual  当前时间减去7小时的时间  sele ...

  9. Spring 基于注解的配置 简介

    基于注解的配置 从 Spring 2.5 开始就可以使用注解来配置依赖注入.而不是采用 XML 来描述一个 bean 连线,你可以使用相关类,方法或字段声明的注解,将 bean 配置移动到组件类本身. ...

  10. 使用element-ui 的table 组件 出现表格线条不对齐的问题

    在全局css样式中添加以下代码即可: body .el-table th.gutter { display: table-cell !important }