我正在尝试使用自动响应来自动化 mysql_secure_installation 脚本。我的代码如下:
echo "& y y abc abc y y y y" | ./usr/bin/mysql_secure_installation
我正在自动化的实际问题如下:
Enter current password for root (enter for none): <enter>
Set root password? [Y/n] y
New password: abc
Re-enter new password: abc
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
但它给了我一个错误“对不起,你不能在这里使用空密码”,但在屏幕上我曾经按第一个问题的返回键。
原文由 cucucool 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以尝试使用让交互式应用程序自动化的 expect 。看看这个 自动化的 mysql_secure_installation 或者我的 修改。