通过debconf-set-selections为mysql预配置一个空密码 [英] preconfigure an empty password for mysql via debconf-set-selections

查看:673
本文介绍了通过debconf-set-selections为mysql预配置一个空密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个bash脚本来自动化LAMP环境的构建.

I am setting up a bash script to automate the building of a LAMP environment.

在安装mysql,phpmyadmin等之前,我正在使用debconf-set-selections设置选项...

I am using debconf-set-selections to set options before installing mysql, phpmyadmin, etc ...

主要效果很好.但是问题是我必须为mysql设置一个空密码,即使在键入之前的行中,它仍然会在安装过程中要求输入密码:

It works mainly great. But the problem is that I have to set an empty password for mysql and it still asks for the password during installation even with the lines typed before :

echo "mysql-server-5.5  mysql-server/root_password  password" | debconf-set-selections
echo "mysql-server-5.5  mysql-server/root_password_again    password" | debconf-set-selections

推荐答案

mysql-server的软件包安装过程中使用debconf-set-selections设置空密码的推荐方法取决于手中的软件包版本.

The recommended approach for setting an empty password during mysql-server's package installation process using debconf-set-selections depends on the package version in hand.

  • MySQL 5.7

  • MySQL 5.7

尽管可以将密码配置为空,但安装过程将自动启用

Although it's possible to configure the password to be empty, the installation process will automatically enable the authentication plugin auth_socket in such a case. Hence, the password-less login shall be conditioned on using UNIX socket based authentication (e.g. requiring the login to be made from the user account root on the local machine).

sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password "
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password "

  • 对于 Ubuntu软件包存储库提供的软件包:

  • For the package provided by the Ubuntu package repositories:

    sudo debconf-set-selections <<< "mysql-server mysql-server/root-password password "
    sudo debconf-set-selections <<< "mysql-server mysql-server/root-password_again password "
    

  • MySQL 5.5和MySQL 5.6

    MySQL 5.5 and MySQL 5.6

    此答案建议的解决方案应该可以起作用,并添加少量的确认空密码的内容:

    The solution suggested by this answer should work, with a minor addition that confirms the empty password:

    sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password \"''\""
    sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password \"''\""
    

    如果所有方法都失败了,则可以防止debconf完全要求用户输入密码,从而可以解决问题并隐式将密码保留为空白.不幸的是,这适用于所有问题,而不仅仅是密码相关的问题.

    If all approaches fail, it's possible to circumvent the issue and implicitly leave the password blank by preventing debconf from asking the user for a password altogether. Unfortunately, this applies to all questions, rather than just the password-related ones.

    这里有两种方法可以达到预期的效果:

    Here are two methods that achieve the desired result:

    • debconf的前端设置为noninteractive:

    DEBIAN_FRONTEND=noninteractive apt-get install [-y] [-q] mysql-server
    

  • debconf的优先级设置为critical:

  • Set debconf's priority level to critical:

    DEBIAN_PRIORITY=critical apt-get install [-y] [-q] mysql-server
    

    此方法可能更可取,因为它可以显示关键消息.

    This method is probably preferable as it permits the display of critical messages.

    这篇关于通过debconf-set-selections为mysql预配置一个空密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆