GreatSQL社区

搜索

reddey

MySQL8.4.6如何安装启用mysql_native_password插件

reddey 已有 14 次阅读2025-10-25 09:43 |系统分类:运维实战



MySQL8.4版本由于安全性能的提高,使用了默认的caching_sha2_password作为密码插件。但由于工作上需要,例如在创建主从复制集群时,从库要连接主库,如果使用默认密码插件,要使用SSL连接,又要创建SSL证书比较麻烦。所以我们要启用mysql_native_password。以下是我的数据库版本:

[root@mdw:/root]#  mysql -uroot -pGood@2019;

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 8.4.6 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();

+-----------+

| version() |

+-----------+

| 8.4.6     |

+-----------+

1 row in set (0.00 sec)

实际上启用mysql_native_password插件也非常简单,只要在配置文件my.cnf中加入如下配置就行:

mysql_native_password=ON

配置好保存后,要重启一下数据库服务(systemctl restart mysqld)

这时,我们再登录数据库查看一下数据库安装的插件。

mysql> show plugins\G

*************************** 1. row ***************************

  Name: binlog

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 2. row ***************************

  Name: sha256_password

Status: ACTIVE

  Type: AUTHENTICATION

Library: NULL

License: GPL

*************************** 3. row ***************************

  Name: caching_sha2_password

Status: ACTIVE

  Type: AUTHENTICATION

Library: NULL

License: GPL

*************************** 4. row ***************************

  Name: sha2_cache_cleaner

Status: ACTIVE

  Type: AUDIT

Library: NULL

License: GPL

*************************** 5. row ***************************

  Name: daemon_keyring_proxy_plugin

Status: ACTIVE

  Type: DAEMON

Library: NULL

License: GPL

*************************** 6. row ***************************

  Name: CSV

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 7. row ***************************

  Name: MEMORY

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 8. row ***************************

  Name: InnoDB

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 9. row ***************************

  Name: INNODB_TRX

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 10. row ***************************

  Name: INNODB_CMP

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 11. row ***************************

  Name: INNODB_CMP_RESET

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 12. row ***************************

  Name: INNODB_CMPMEM

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 13. row ***************************

  Name: INNODB_CMPMEM_RESET

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 14. row ***************************

  Name: INNODB_CMP_PER_INDEX

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 15. row ***************************

  Name: INNODB_CMP_PER_INDEX_RESET

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 16. row ***************************

  Name: INNODB_BUFFER_PAGE

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 17. row ***************************

  Name: INNODB_BUFFER_PAGE_LRU

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 18. row ***************************

  Name: INNODB_BUFFER_POOL_STATS

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 19. row ***************************

  Name: INNODB_TEMP_TABLE_INFO

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 20. row ***************************

  Name: INNODB_METRICS

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 21. row ***************************

  Name: INNODB_FT_DEFAULT_STOPWORD

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 22. row ***************************

  Name: INNODB_FT_DELETED

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 23. row ***************************

  Name: INNODB_FT_BEING_DELETED

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 24. row ***************************

  Name: INNODB_FT_CONFIG

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 25. row ***************************

  Name: INNODB_FT_INDEX_CACHE

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 26. row ***************************

  Name: INNODB_FT_INDEX_TABLE

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 27. row ***************************

  Name: INNODB_TABLES

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 28. row ***************************

  Name: INNODB_TABLESTATS

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 29. row ***************************

  Name: INNODB_INDEXES

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 30. row ***************************

  Name: INNODB_TABLESPACES

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 31. row ***************************

  Name: INNODB_COLUMNS

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 32. row ***************************

  Name: INNODB_VIRTUAL

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 33. row ***************************

  Name: INNODB_CACHED_INDEXES

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 34. row ***************************

  Name: INNODB_SESSION_TEMP_TABLESPACES

Status: ACTIVE

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 35. row ***************************

  Name: MyISAM

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 36. row ***************************

  Name: MRG_MYISAM

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 37. row ***************************

  Name: PERFORMANCE_SCHEMA

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 38. row ***************************

  Name: TempTable

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 39. row ***************************

  Name: ARCHIVE

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 40. row ***************************

  Name: BLACKHOLE

Status: ACTIVE

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 41. row ***************************

  Name: FEDERATED

Status: DISABLED

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 42. row ***************************

  Name: ndbcluster

Status: DISABLED

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 43. row ***************************

  Name: ndbinfo

Status: DISABLED

  Type: STORAGE ENGINE

Library: NULL

License: GPL

*************************** 44. row ***************************

  Name: ndb_transid_mysql_connection_map

Status: DISABLED

  Type: INFORMATION SCHEMA

Library: NULL

License: GPL

*************************** 45. row ***************************

  Name: ngram

Status: ACTIVE

  Type: FTPARSER

Library: NULL

License: GPL

*************************** 46. row ***************************

  Name: mysqlx_cache_cleaner

Status: ACTIVE

  Type: AUDIT

Library: NULL

License: GPL

*************************** 47. row ***************************

  Name: mysqlx

Status: ACTIVE

  Type: DAEMON

Library: NULL

License: GPL

*************************** 48. row ***************************

  Name: mysql_native_password

Status: ACTIVE

  Type: AUTHENTICATION

Library: NULL

License: GPL

*************************** 49. row ***************************

  Name: rpl_semi_sync_master

Status: ACTIVE

  Type: REPLICATION

Library: semisync_master.so

License: GPL

49 rows in set (0.01 sec)

48. row中,我们看到mysql_native_password启用了,状态是激活的。以后我们创建或修改用户时就可以使用这种密码认证方式了,记得要带上mysql_native_password

注:通常我们在做一些集群方面的实验时,有些细节会导致集群搭建失败。这些细节是搭建集群的前提条件,但由于过于微小,通常大家会选择忽略或者行文时把这个环节放在一个不为人知的小角落。自己踩过的坑,自己一定要记下。

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2025-10-25 21:06 , Processed in 0.014888 second(s), 9 queries , Redis On.
返回顶部