Install MySQL on Ubuntu without a password prompt

后端 未结 4 1462
死守一世寂寞
死守一世寂寞 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条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 09:21

    Another way to make it work:

    echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections
    echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections
    apt-get -y install mysql-server-5.5
    

    Note that this simply sets the password to "root". I could not get it to set a blank password using simple quotes '', but this solution was sufficient for me.

    Based on a solution here.

提交回复
热议问题