aus*_*inc 5 mysql linux bash shell centos
我的操作系统是 CentOS 6.6,我想知道如何通过 shell 脚本自动安装 mysql-server。
我发现有一个主题讨论了同样的问题,但它在 CentOS 6 上失败:在 ubuntu 上安装 mysql,没有密码提示
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'
Run Code Online (Sandbox Code Playgroud)
错误信息是
bash: debconf-set-selections: command not found
Run Code Online (Sandbox Code Playgroud)
这是我的基本脚本
#!/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
Run Code Online (Sandbox Code Playgroud)
是否有任何方法可以自动填充 root 密码并对大多数安全问题回答“y”。
或者它有替代方法来实现相同的目标。即自动安装 myaql-server 且无需密码提示的脚本。
非常感谢您的帮助。
| 归档时间: |
|
| 查看次数: |
2343 次 |
| 最近记录: |