我的操作系统是 CentOS 6.6,我想知道如何通过 shell 脚本自动安装 mysql-server。
我发现有一个主题讨论了同样的问题,但在 CentOS 6 上失败了:ubuntu安装mysql无密码提示 https://stackoverflow.com/questions/7739645/install-mysql-on-ubuntu-without-password-prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
错误信息是
bash: debconf-set-selections: command not found
这是我的基本脚本
#!/bin/sh
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#password setting
root_password='abc123'
#install mysql-server
yum install mysql mysql-server
#start service
service mysqld start
#MySQL Initial Setup
mysql_secure_installation
#This command needs root password and answers(y/n) for secure questions
是否有任何方法可以自动填充 root 密码并对大多数安全问题回答“y”。
或者它有替代方法来实现相同的目标。即自动安装 mysql-server 且无需密码提示的脚本。
非常感谢您的帮助。
mysql_secure_installation 是一个 shell 脚本。
因此您可以在脚本或任何其他用户交互部分中编辑 set_root_password() 函数。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)