gpt4 book ai didi

mysql - 如何在 debian 中安装 mysql-server :buster using script without being asked any configuration questions?

转载 作者:行者123 更新时间:2023-11-29 09:25:52 30 4
gpt4 key购买 nike

当我运行此命令时,我尝试使用 Dockerfile 和 shell 脚本在 debian:buster 中安装 mysql-server

apt install -y mysql-server 在安装过程中我需要输入密码并重新输入,如图所示:

enter image description here

我做了一些搜索,发现如何使用本页 Install MySQL on Ubuntu without a password prompt 中的此处字符串来做到这一点

因为我正在使用这个命令apt install -y mysql-server我这样做了:

debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
apt-get -y install mysql-server

但是当我运行它们时,我仍然得到同样的结果,并且我需要输入密码。

这是我的 Dockerfile:

From debian:buster

COPY ./run.sh /

CMD bash /run.sh

这是 run.sh:

apt update
apt install -y nginx gnupg wget lsb-release
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
printf "1\n1\n4\n" | dpkg -i mysql-apt-config_0.8.13-1_all.deb //version selected is mysql-5.7
apt update
service nginx start
bash //just to stay in the bash of container and don't quit from it.

顺便说一下,我正在尝试从容器的 bash 内部安装 mysql-server,然后我将在脚本中编写命令。

正如您在上图中看到的那样,有一些奇怪的东西:

Configuring mysql-community-server
----------------------------------

即使我使用此命令安装 apt-get -y install mysql-server 也不是这个

apt-get -y install mysql-community-server

那么你知道我在这里错过了什么吗?

最佳答案

使用

shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password mypassword"
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password mypassword"
shell> sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server

Documentation

关于mysql - 如何在 debian 中安装 mysql-server :buster using script without being asked any configuration questions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59618948/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com