gpt4 book ai didi

mysql - 脚本通过 CentOS 无密码提示安装 mysql-server

转载 作者:IT王子 更新时间:2023-10-29 00:34:16 25 4
gpt4 key购买 nike

我的操作系统是CentOS 6.6,想知道如何通过shell脚本自动安装mysql-server。

我发现有一个话题讨论了同样的问题,但它在 CentOS 6 上失败了: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”。

或者它有替代方法来实现同样的事情。即,自动安装 myaql-server 且无需密码提示的脚本。

非常感谢您的帮助。

最佳答案

mysql_secure_installation 是一个 shell 脚本。因此您可以在脚本或任何其他用户交互部分中编辑 set_root_password() 函数。

关于mysql - 脚本通过 CentOS 无密码提示安装 mysql-server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31805195/

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