1
我需要工作人員做一個shell腳本來安裝yum的mysql服務器但是需要安裝它自動設置root密碼mysql! 大多數人不知道如何做到這一點,誰能幫助我?安裝mysql shellscript並設置root密碼
我需要工作人員做一個shell腳本來安裝yum的mysql服務器但是需要安裝它自動設置root密碼mysql! 大多數人不知道如何做到這一點,誰能幫助我?安裝mysql shellscript並設置root密碼
一種方式將是以後指定密碼(當你知道默認)
mysqladmin -u root password <NEW_PASS>
你可以試着使你的腳本的一部分。
另一種方式將使用here-strings。
它基本上會是這個樣子:
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password <NEW_PASS>'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password <NEW_PASS>'
sudo apt-get -y install mysql-server
第三條道路是使用一個真正的供應框架像廚師或木偶等,在您使用的文件來描述某種類型的節點,類似於:
class mysql-server {
$password = "insert_password_here"
package { "MySQL-client": ensure => installed }
package { "MySQL-server": ensure => installed }
package { "MySQL-shared": ensure => installed }
exec { "Set MySQL server root password":
subscribe => [ Package["MySQL-server"], Package["MySQL-client"], Package["MySQL-shared"] ],
refreshonly => true,
unless => "mysqladmin -uroot -p$password status",
path => "/bin:/usr/bin",
command => "mysqladmin -uroot password $password",
}
}
查看完整的文章here。
此外資源:
[1]的配置管理mysql with chef
[2]配置管理mysql with Puppet