我正在编写一个简单的bash脚本来在Ubuntu上安装MysqL。
#!/bin/bash apt-get update # Install MysqL5 aptitude -y install MysqL-server MysqL-client libMysqLclient15-dev@H_502_3@但MysqL提示输入密码并确认。如何传递root密码?有可以使用的回声吗?
这样更容易
@H_502_3@install mysql on ubuntu without password prompt
sudo debconf-set-selections <<< 'MysqL-server-5.1 MysqL-server/root_password password your_password' sudo debconf-set-selections <<< 'MysqL-server-5.1 MysqL-server/root_password_again password your_password' sudo apt-get -y install MysqL-server@H_502_3@如果你的shell不支持这里的字符串(zsh,ksh93和bash支持它们),请使用:
echo ... | sudo debconf-set-selections