脚本通过CentOS安装没有密码提示的mysql-server [英] Script Install mysql-server without password prompt via CentOS

查看:121
本文介绍了脚本通过CentOS安装没有密码提示的mysql-server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My OS is CentOS 6.6 and I want to know how to install mysql-server automatically via shell script.

我发现有一个话题谈论同样的问题,但是在CentOS 6上失败了:

I have found that there is a topic talked about the same issue but it failed on 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".

Does there have any methods to automatically fill the root password and answer 'y' to most of the secure question.

或者它具有实现同一件事的替代方法.也就是说,一个脚本会自动安装myaql-server,而不会提示输入密码.

Or it have alternative way to achieve the same thing. That is, a script to install myaql-server automatically and without password prompt.

非常感谢您的帮助.

推荐答案

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

mysql_secure_installation is a shell script. so you can edit set_root_password() function in the script or any other user interactive sections.

这篇关于脚本通过CentOS安装没有密码提示的mysql-server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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