Install MySQL on Ubuntu without a password prompt

后端 未结 4 1476
死守一世寂寞
死守一世寂寞 2020-11-27 09:04

How do I write a script to install MySQL server on Ubuntu?

sudo apt-get install mysql will install, but it will also ask for a password to be entered in

4条回答
  •  旧时难觅i
    2020-11-27 09:31

    This should do the trick

    export DEBIAN_FRONTEND=noninteractive
    sudo -E apt-get -q -y install mysql-server
    

    Of course, it leaves you with a blank root password - so you'll want to run something like

    mysqladmin -u root password mysecretpasswordgoeshere
    

    Afterwards to add a password to the account.

提交回复
热议问题