zoukankan      html  css  js  c++  java
  • MySQL8 修改密码验证插件

    MySQL8 修改密码验证插件

    查看当前用户使用的密码验证插件

    mysql> show variables like '%auth%';
    +-------------------------------+-----------------------+
    | Variable_name                 | Value                 |
    +-------------------------------+-----------------------+
    | default_authentication_plugin | caching_sha2_password |
    +-------------------------------+-----------------------+
    

    查看 MySQL8 支持的密码验证插件

    mysql> show plugins;
    +----------------------------+----------+--------------------+---------+---------+
    | Name                       | Status   | Type               | Library | License |
    +----------------------------+----------+--------------------+---------+---------+
    | binlog                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
    | mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
    | sha256_password            | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
    | caching_sha2_password      | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
    | sha2_cache_cleaner         | ACTIVE   | AUDIT              | NULL    | GPL     |
    | CSV                        | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
    

    修改用户的密码验证插件

    mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root';
    Query OK, 0 rows affected (0.45 sec)
    

    修改系统默认的密码验证插件

    1. 配置参数方式 default-authentication-plugin
    # 设置默认密码验证插件
    default-authentication-plugin=caching_sha2_password
    
    1. 启动参数方式 --default-authentication-plugin
    C:Usersjie>D:chengxuMySQLmysql-8.0.12-winx64inmysqld --default-authentication-plugin=mysql_native_password
    

    bugs

    如果只指定用户名不指定主机,则表示的用户是任意主机,即 'username'@'%',这个和本地主机即 'username'@'localhost' 的含义是不同的。

    # 'root' 更改失败,因为表示的是 'root'@'%',而此处用户只有'root'@'localhost'
    mysql> alter user 'root' identified with mysql_native_password by 'root';
    ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
    
    mysql> select host, user, plugin from mysql.user;
    +-----------+------------------+-----------------------+
    | host      | user             | plugin                |
    +-----------+------------------+-----------------------+
    | localhost | caocao           | caching_sha2_password |
    | localhost | liubei           | caching_sha2_password |
    | localhost | mysql.infoschema | caching_sha2_password |
    | localhost | mysql.session    | caching_sha2_password |
    | localhost | mysql.sys        | caching_sha2_password |
    | localhost | root             | caching_sha2_password |
    +-----------+------------------+-----------------------+
    

    无法通过命令行方式设置默认的密码验证插件

    mysql> set default_authentication_plugin=mysql_native_password;
    ERROR 1238 (HY000): Variable 'default_authentication_plugin' is a read only variable
    mysql> set global default_authentication_plugin=mysql_native_password;
    ERROR 1238 (HY000): Variable 'default_authentication_plugin' is a read only variable
    
  • 相关阅读:
    Map之类的东西
    [待码][BZOJ1858]SCOI2010序列操作 jzyzoj1655
    Linux 系统时间和硬件时间
    自动化运维之puppet的学习(如何找到你需要的模块)
    linux 搭建hexo博客
    坚持不懈之linux haproxy的配置文件关键字查询手册
    坚持不懈之linux haproxy 配置文件 详情
    Linux Haproxy 安装和部署
    linux 破解版confluence安装
    zookeeper 简介
  • 原文地址:https://www.cnblogs.com/mozq/p/11623918.html
Copyright © 2011-2022 走看看