bry*_*yan 4 security mysql login
我想从 shell 登录到 MySQL 数据库。
通常我使用
mysql -p
Run Code Online (Sandbox Code Playgroud)
但我刚刚在 MySQL 帮助中注意到以下内容:
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty. WARNING: This is
insecure as the password is visible for anyone through
/proc for a short time.
Run Code Online (Sandbox Code Playgroud)
这是说以下不安全吗?
mysql -p=mypassword
Run Code Online (Sandbox Code Playgroud)
或者所有的使用-p 都是不安全的?
小智 6
只有这样是不安全的:
mysql -p=mypassword
Run Code Online (Sandbox Code Playgroud)
因为这样它可以在ps用于查看命令行参数时可见。简而言之,始终使用该-p选项,并在需要自动化时使用“选项文件”
有关更多信息,请参阅http://dev.mysql.com/doc/refman/5.0/en/password-security-user.html:
这很方便但不安全,因为您的密码对系统状态程序(例如 ps)可见,其他用户可能会调用这些程序来显示命令行。MySQL 客户端通常在初始化序列期间用零覆盖命令行密码参数。但是,仍然有一个短暂的时间间隔,在此期间该值是可见的。此外,在某些系统上,这种覆盖策略无效,密码对 ps 仍然可见。(SystemV Unix 系统以及其他系统可能会遇到此问题。)