[英]Installing Percona/MySQL unattended on Ubuntu
I can install MYSQL on Ubuntu without prompts with the code below: 我可以在Ubuntu上安装MYSQL而不提示下面的代码:
dbpass="mydbpassword"
export DEBIAN_FRONTEND=noninteractive
echo mysql-server-5.1 mysql-server/root_password password $dbpass | debconf-set-selections
echo mysql-server-5.1 mysql-server/root_password_again password $dbpass | debconf-set-selections
apt-get -y install mysql-server
The part with the debconf-set-selections I got somewhere online (could be here can't remember) and it has worked ok for me thus far. 有debconf-set-selections的部分我在网上找到了某个地方(可能在这里不记得了)到目前为止它对我来说还算合适。 I'm not that much of an expert to understand how it works but it does. 我不是那么了解它是如何工作的专家,但确实如此。
However, I want to do the same thing for Percona. 但是,我想为Percona做同样的事情。 I've setup the apt package manager to deal with using apt-get for percona. 我已经设置了apt包管理器来处理使用apt-get for percona。 So now my code is the following: 所以现在我的代码如下:
dbpass="dbpass" && export dbpass
export DEBIAN_FRONTEND=noninteractive
echo percona-server-server-5.5 percona-server-server-5.5/root_password password $dbpass | debconf-set-selections
echo percona-server-server-5.5 percona-server-server-5.5/root_password_again password $dbpass | debconf-set-selections
apt-get -y install percona-server-server-5.5
However, Percona installs but without a password as defined. 但是,Percona安装但没有定义的密码。 I know I'm missing something in the debconf bit. 我知道我在debconf中丢失了一些东西。
I'd appreciate some guidance here. 我在这里感谢一些指导。
Thanks in advance. 提前致谢。
I actually found that the answer here install mysql on ubuntu without password prompt that suggested 我实际上发现这里的答案在ubuntu上安装mysql而没有建议的密码提示
export DEBIAN_FRONTEND=noninteractive apt-get -q -y install mysql-server
Worked and left me with a root user with no password, which is what I wanted. 工作并留给我一个没有密码的root用户,这就是我想要的。
The second part of the debconf-prefix
should not contain the version number: debconf-prefix
的第二部分不应包含版本号:
echo percona-server-server-5.5 percona-server-server/root_password password $dbpass | sudo debconf-set-selections
echo percona-server-server-5.5 percona-server-server/root_password_again password $dbpass | sudo debconf-set-selections
For 5.6: 对于5.6:
echo percona-server-server-5.6 percona-server-server/root_password password $dbpass | sudo debconf-set-selections
echo percona-server-server-5.6 percona-server-server/root_password_again password $dbpass | sudo debconf-set-selections
If you understand what is going on underneath the hood it makes it easier to debug and figure out why this isn't working. 如果你了解底层发生了什么,它就可以更容易地进行调试,并弄清楚为什么这样做不起作用。
When you install a debian package often times you get questions about licenses, passwords, locations, etc. All of those values are stored in debconf. 当您经常安装debian软件包时,会遇到有关许可证,密码,位置等的问题。所有这些值都存储在debconf中。 If you are wanting to do an unattended installation you can preload those answers into debconf so you aren't prompted for those questions, since they are already answered. 如果您想要进行无人参与安装,可以将这些答案预先加载到debconf中,这样就不会提示您提出这些问题,因为它们已经得到了解答。
The challenge comes when understanding how to properly answer those questions. 当理解如何正确回答这些问题时,就会遇到挑战。 To do this you first need to install the debconf-utils 要做到这一点,首先需要安装debconf-utils
apt install debconf-utils
next you need to manually install your package. 接下来你需要手动安装你的包。
In my case I am installing the percona-xtradb-cluster-57 package. 在我的情况下,我正在安装percona-xtradb-cluster-57软件包。
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
sudo apt-get update -y
sudo apt-get install -y percona-xtradb-cluster-57
After this has been installed you can get the selections that have been set by using the deb-get-selections
tool. 安装完成后,您可以使用deb-get-selections
工具deb-get-selections
已设置deb-get-selections
。
debconf-get-selections | grep percona
In the response you will see the selections that were set. 在响应中,您将看到已设置的选择。 In this case 在这种情况下
percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/root-pass password
percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/re-root-pass password
percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/remove-data-dir boolean false
percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/root-pass-mismatch error
percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/data-dir note
You can now copy the values that you want to set. 您现在可以复制要设置的值。 In my case I want automatically set the root password. 在我的情况下,我想自动设置root密码。
In your automated installation script you can now use the debconf-set-selections
tool to automate setting the values for the root password question and the confirm root password question. 在自动安装脚本中,您现在可以使用debconf-set-selections
工具自动设置root密码问题和确认root密码问题的值。
echo "percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/root-pass password my_temp_password" | debconf-set-selections
echo "percona-xtradb-cluster-server-5.7 percona-xtradb-cluster-server-5.7/re-root-pass password my_temp_password" | debconf-set-selections
Happy Automating! 快乐的自动化!
Think I figured it out 想想我明白了
echo "percona-server-server-5.5 mysql-server/root_password password mypassword" | debconf-set-selections
echo "percona-server-server-5.5 mysql-server/root_password_again password mypassword" | debconf-set-selections
Don't use export DEBIAN_FRONTEND=noninteractive
. 不要使用export DEBIAN_FRONTEND=noninteractive
。 If the debconf entries are correct, then you won't be prompted anyway. 如果debconf条目是正确的,那么无论如何都不会提示您。 If they are incorrect and you use noninteractive
then the prompt will continue with a blank password. 如果它们不正确并且您使用noninteractive
则提示将继续使用空白密码。
Since Percona 'hooks into' MySQL check that it installed correctly using 由于Percona'钩入'MySQL检查它是否正确使用安装
service mysql status
and you will know it is percona if you see something like 如果你看到类似的东西,你会知道它是percona
mysql.service - LSB: Start and stop the mysql (Percona Server) daemon mysql.service - LSB:启动和停止mysql(Percona Server)守护进程
Then finally check the password was set correctly 然后最后检查密码设置是否正确
mysql -u user -pmypassword
EDIT: That said, for a newer version of percona, F21 's answer worked for me. 编辑:那就是说,对于更新版本的percona, F21的回答对我有用。 You can check the entries in /var/cache/debconf/passwords.dat
您可以检查/var/cache/debconf/passwords.dat
的条目
you can always do normal installation and then script: 你总是可以做正常的安装,然后脚本:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.