英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论