Joe*_*way 70 mysql linux ubuntu debian
我被 'debian-sys-maint' 用户咬了好几次,该用户默认安装在从 Ubuntu 存储库安装的 mysql-server 软件包上。
通常发生的情况是我拉出我们生产数据库的新副本(它不在 Debian/Ubuntu 上运行)用于故障排除或新开发,但忘记排除 mysql.user 表,从而丢失 debian-sys-maint 用户。
如果我们出于任何原因添加新的 mysql 用户,我必须将它们“合并”到我的开发环境中,而不是仅仅覆盖表。
如果没有用户,我的系统似乎仍然可以正常运行,但受到以下错误的困扰:
sudo /etc/init.d/mysql restart
Stopping MySQL database server: mysqld...failed.
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
Run Code Online (Sandbox Code Playgroud)
编辑
附加问题 - /etc/mysql/debian.cnf 中的密码是否已经散列,还是明文密码?当你重新创建用户时很重要,我似乎从来没有在第一次尝试时就做对了。
谢谢
Zor*_*che 59
debian-sys-maint 有什么用?
它的主要用途是告诉服务器滚动日志。它至少需要重新加载和关闭权限。
查看文件/etc/logrotate.d/mysql-server
/etc/init.d/mysql脚本使用它来获取服务器的状态。它用于正常关闭/重新加载服务器。
这是 README.Debian 中的引用
* MYSQL WON'T START OR STOP?:
=============================
You may never ever delete the special mysql user "debian-sys-maint". This user
together with the credentials in /etc/mysql/debian.cnf are used by the init
scripts to stop the server as they would require knowledge of the mysql root
users password else.
Run Code Online (Sandbox Code Playgroud)
丢失后最简单的恢复方法是什么?
最好的计划就是不要失去它。如果您确实丢失了密码,请使用其他帐户重置密码。如果您丢失了 mysql 服务器上的所有管理员权限,请按照指南重置 root 密码,然后修复debian-sys-maint.
您可以使用这样的命令来构建 SQL 文件,稍后您可以使用该文件重新创建帐户。
mysqldump --complete-insert --extended-insert=0 -u root -p mysql | grep 'debian-sys-maint' > debian_user.sql
Run Code Online (Sandbox Code Playgroud)
/etc/mysql/debian.cnf 中的密码是否已经散列
安装时密码未散列/加密,但新版本的 mysql 现在有一种方法来加密凭据(请参阅:https : //serverfault.com/a/750363)。
Bre*_*nt 23
所述的Debian-SYS-MAINT用户缺省为根当量。它被 Debian 系统上的某些维护脚本使用,作为副作用,它允许具有 root 访问权限的用户在 /etc/mysql/debian.cnf 中查看明文密码(好还是坏?)
您可以通过以下方式重新创建用户:
GRANT ALL PRIVILEGES on *.* TO `debian-sys-maint`@`localhost` IDENTIFIED BY 'your password' WITH GRANT OPTION;
Run Code Online (Sandbox Code Playgroud)
只需确保密码与/etc/mysql/debian.cnf 中的密码匹配
小智 20
你也可以:
sudo dpkg-reconfigure mysql-server-5.0
Run Code Online (Sandbox Code Playgroud)
这将为您提供重新创建 debian-sys-maint 用户的选项。现有用户和数据库是安全的。
d-_*_*_-b 20
我只想发表评论,但我认为正确的语法值得它自己的条目。这将创建debian-sys-maint用户:
mysql> GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'plaintextpassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
Run Code Online (Sandbox Code Playgroud)
如果您还有 /etc/mysql/debian.cnf 文件,只需使用其中的密码即可。
随意想出一个更偏执的安全解决方案。
如果您需要添加debian-sys-maint用户只需为logrotate.d目的,您应该不授予ALL PRIVILEGES或GRANT OPTION-这是一种不必要的巨大的安全漏洞。相反,您可以添加具有这样RELOAD权限的用户(假设您正在访问您的数据库root,并且您将 xxxxxx 替换为您的密码)
# add the user with the reload right
GRANT RELOAD on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'xxxxxx';
# reload the rights
FLUSH PRIVILEGES;
# double check
select * from mysql.user;
Run Code Online (Sandbox Code Playgroud)
2019年更新
此答案可能已过时 - 请参阅下面的强烈意见。
| 归档时间: |
|
| 查看次数: |
105156 次 |
| 最近记录: |