Automate mysql_secure_installation with echo command via a shell script

后端 未结 11 1032
无人共我
无人共我 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:09

    sudo mysql -e "SET PASSWORD FOR root@localhost = PASSWORD('123');FLUSH PRIVILEGES;" 
    
    printf "123\n n\n n\n n\n y\n y\n y\n" | sudo mysql_secure_installation
    

    Enter current password for root (enter for none)? (I have 123 set for root)

    Switch to unix_socket authentication? n

    Change the root password? n

    Remove anonymous users? n

    Disallow root login remotely? y

    Remove test database and access to it? y

    Reload privilege tables now? y

    Version: mysql Ver 15.1 Distrib 10.4.6-MariaDB, for osx10.14 (x86_64) using readline 5.1

提交回复
热议问题