值 | 策略 |
'*' | 仅允许使用单因素认证 |
'*,*' | 仅允许使用2因素认证 |
'*,*,*' | 仅允许使用3因素认证 |
'*,' | 允许使用单因素或2因素认证 |
'*,,' | 允许使用单因素、2因素或3因素认证 |
'*,*,' | 允许使用2因素或3因素认证 |
'*,auth_plugin' | 允许使用2因素认证,第一个因素可以使用任意方法,第二因素必须使用指定的认证插件 |
'auth_plugin,*,' | 允许使用2因素或3因素认证,第一个因素必须使用指定的认证插件 |
'auth_plugin,' | 允许使用单因素或2因素认证,第一个因素必须使用指定的认证插件 |
'auth_plugin,auth_plugin,auth_plugin' | 允许使用3因素认证,并且必须使用指定的认证的插件 |
注意:使用内部存储的认证插件必须作为第一个因素,并且不能重复出现,如下情况会出现错误:
authenication_policy = 'caching_sha2_password, sha256_password'authentication_policy = 'caching_sha2_password, authetication_fido, sha256_password'MySQL localhost:3350 ssl SQL > CREATE USER 'powerdba'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Welcome01' and IDENTIFIED WITH caching_sha2_password BY 'Welcome02';ERROR: 4052 (HY000): Invalid plugin "caching_sha2_password" specified as 2 factor during "CREATE USER".
正确的使用方法如下,本例第一个因素使用caching_sha2_password,第二个因素使用authentication_windows。
SQL > CREATE USER powerdba IDENTIFIED WITH caching_sha2_password BY 'Welcome01' AND IDENTIFIED WITH authentication_windows AS '"YITAO.XU"';
登录MySQL时,指定—password1,—password2
D:\mysql-commercial-8.0.31-winx64\mysql-commercial-8.0.31-winx64\bin>mysql --port=3310 --user=powerdba --password1 --password2Enter password: *********Enter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 18Server version: 8.0.31-commercial MySQL Enterprise Server - CommercialCopyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
以上内容是关于MySQL多因素身份认证的一个简介,感兴趣的读者可以体验试用。
感谢关注“MySQL解决方案工程师”
我的新书《MySQL高可用解决方案——从主从复制到InnoDB Cluster》已经上市,感兴趣的朋友可以通过下面的链接购买。
文章转载自MySQL解决方案工程师,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




