preconfigure an empty password for mysql via debconf-set-selections(通过 debconf-set-selections 为 mysql 预配置一个空密码)
问题描述
I am setting up a bash script to automate the building of a LAMP environment.
I am using debconf-set-selections to set options before installing mysql, phpmyadmin, etc ...
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
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
Although it's possible to configure the password to be empty, the installation process will automatically enable the authentication plugin
auth_socketin such a case. Hence, the password-less login shall be conditioned on usingUNIXsocket based authentication (e.g. requiring the login to be made from the user accountrooton the local machine).For the package provided by the MySQL APT repository:
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 "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 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 "''""
A fallback solution
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:
Set
debconf's frontend tononinteractive:DEBIAN_FRONTEND=noninteractive apt-get install [-y] [-q] mysql-serverSet
debconf's priority level tocritical:DEBIAN_PRIORITY=critical apt-get install [-y] [-q] mysql-serverThis method is probably preferable as it permits the display of critical messages.
这篇关于通过 debconf-set-selections 为 mysql 预配置一个空密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过 debconf-set-selections 为 mysql 预配置一个空密码
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
