微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

脚本通过CentOS安装没有密码提示的mysql-server

我的操作系统是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()函数.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐