通过shell脚本使用echo命令自动执行mysql_secure_installation [英] Automate mysql_secure_installation with echo command via a shell script

查看:469
本文介绍了通过shell脚本使用echo命令自动执行mysql_secure_installation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用自动响应来自动化mysql_secure_installation脚本.我的代码如下:

I am trying to automate mysql_secure_installation script with automated response. My code is as follows :

echo "& y y abc abc y y y y" | ./usr/bin/mysql_secure_installation

我要自动化的实际问题如下:

The actual questions which i am automating are as follows:

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

但是它给了我一个错误很抱歉,您不能在此处使用空密码",但是在屏幕上,我习惯按第一个问题的返回键.

But it gives me an error "Sorry you cannot use an empty password here" but in the screen i used to press the return key for the first question.

推荐答案

您可以尝试使用期望. 查看此自动化mysql_secure_installation 或我的

You can try to use expect. Look at this automating mysql_secure_installation or at my modification.

这篇关于通过shell脚本使用echo命令自动执行mysql_secure_installation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆