测试是否在 mariadb 数据库中启用了 Unix 身份验证方法。

huangapple go评论56阅读模式
英文:

Test if the Unix Authentication method is enabled in a mariadb database

问题

我编写了一个Bash脚本来备份和恢复我的MariaDB数据库。有没有一种方法可以在脚本中检查Unix身份验证方法是否已启用?如果我将10.3数据库升级到10.6,Unix身份验证方法将不可用,我需要要求输入DB root密码。我想要一种检查这种可能性的方法。

英文:

I wrote a bash script to backup and restore my MariaDB database. Is there a way to check in a script if the Unix Authentication method is enabled? If I upgrade a 10.3 database to 10.6 the Unix Authentication method is not available and I need to require the DB root password. I'd like to have a method to check for this possibility.

答案1

得分: 1

Unix socket authentication 默认在 MariaDB 10.4 及更高版本中启用,并已静态编译到 mariadbd 中。

MariaDB [(none)]> SELECT plugin_name, plugin_library FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name="unix_socket";
+-------------+----------------+
| plugin_name | plugin_library |
+-------------+----------------+
| unix_socket | NULL           |
+-------------+----------------+

如果您无法作为 root 用户连接,有两个可能的原因:

  • root 用户的凭据需要另一种身份验证方法

  • 您未连接到 localhost。例如,使用 hostname=127.0.0.1 连接会通过 TCP/IP 连接,而不是通过 unix_socket 连接。

英文:

Unix socket authentication is enabled by default since MariaDB 10.4 and statically compiled into mariadbd.

MariaDB [(none)]> SELECT plugin_name, plugin_library FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name="unix_socket";
+-------------+----------------+
| plugin_name | plugin_library |
+-------------+----------------+
| unix_socket | NULL           |
+-------------+----------------+

If you can't connect as root user, there are two possible reasons:

  • The credentials for root user require another authentication method

  • You don't connect to localhost. hostname=127.0.0.1 for example connects via TCP/IP but not via unix_socket.

huangapple
  • 本文由 发表于 2023年5月6日 22:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189362.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定