Files
nexus/wiki/concepts/Socket-登录.md

37 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Socket 登录
## Concept Information
- **Type**: Concept
- **Status**: Active
- **Source**: [[mysql-mariadb-数据库详细信息]]
## Definition
Socket 登录是一种通过 Unix socket 文件进行本地数据库认证的方式,不需要网络连接,适用于服务器本地管理员访问。
## How It Works
当使用 `-S /path/to/socket` 参数连接 MariaDB/MySQL 时,数据库服务器通过检查 socket 文件的进程所有权来验证用户身份,而不是通过网络传输密码。
## Example Command
```bash
sudo mysql -u root -p -S /run/mysqld/mysqld10.sock
```
## Key Characteristics
- **无需网络**:不经过 TCP/IP直接通过文件系统通信
- **更安全**:不暴露密码到网络,避免中间人攻击
- **仅限本地**:只能从数据库服务器本机执行
- **系统用户映射**:依赖操作系统用户身份
## Use Cases
1. 数据库初始配置
2. 密码重置
3. 创建远程访问用户
4. 紧急修复
## Related Concepts
- [[用户权限]] — Host+User 组合权限模型
- [[MariaDB]] — 使用 socket 登录进行本地管理
## Related Entities
- [[群晖 NAS]] — MariaDB socket 登录的目标服务器