Automate mysql_secure_installation with echo command via a shell script

后端 未结 11 1051
无人共我
无人共我 2020-12-12 12:46

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/mysq         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 13:26

    I am using simple command to change root password after MySql installation ,But getting the Above error (signal 9 kill)

    (FATAL: Chef::Exceptions::ChildConvergeError: Chef run process terminated by signal 9 (KILL)) Though the command works and password is changed the error is confusing.
    script "change password" do
    interpreter "bash"
    user "root"
    cwd "/tmp"
    code <<-EOH
    #MYSQL
    root_temp_pass=$(grep 'A temporary password' /mysql/log/mysqld.log |tail -1 |awk '{split($0,a,": "); print a[2]}')
    
    #Login as root change password
    mysql -uroot -p"$root_temp_pass" -Be "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Czt732ck#';" --connect-expired-password
    EOH
    end
    

提交回复
热议问题