在 Ubuntu 中没有密码提示的情况下安装 MariaDB

Has*_*ena 5 mariadb ubuntu installation

我需要在没有密码提示的情况下在 Ubuntu 中安装 MariaDB 服务器。为此,我执行了以下命令,但它没有给我任何进展。它再次显示密码提示。

我使用了以下命令:

  export DEBIAN_FRONTEND=noninteractive
  echo mariadb-server-5.5 mariadb-server/root_password password mypass | debconf-set-selections
  echo mariadb-server-5.5 mariadb-server/root_password_again password mypass | debconf-set-selections
  sudo apt-get -y install mariadb-server
Run Code Online (Sandbox Code Playgroud)

我还检查了堆栈溢出中的一些链接,但它不起作用:

/sf/ask/569704551/

/sf/ask/541775181/

请在这方面帮助我。我的代码有问题吗?

小智 6

mysql/mariadb-Nameing 的混合对我有用:

export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password rootpass'
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password rootpass'
Run Code Online (Sandbox Code Playgroud)


小智 1

我相信您只需使用 mysql 命令,因为它是向后兼容的:

echo 'mysql-server mysql-server/root_password password test
mysql-server mysql-server/root_password_again password test' > /root/src/debconf.txt
debconf-set-selections /root/src/debconf.txt
Run Code Online (Sandbox Code Playgroud)