Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

MySQL | mysql-serverのcuiインストール時にパスワード入力のプロンプトを表示しないようにする

概要

mysql-serverのcuiインストール時にパスワード入力のプロンプトを表示しないようにする

詳細

mysql-serverのcuiインストール時にパスワード入力のプロンプトを表示しないようにします。
通常下記のようにmysql-serverをインストールすると、途中でパスワード確認のプロンプトが3回表示されるため
Chef等のツールで自動インストールすることが出来ません。

そこで、Ubuntuのdebconf-set-selectionsを利用します

# パスを仮にrootで設定
vagrant@vbbinstubs:~$ sudo debconf-set-selections <<< 'mysql-server-5.5.34 mysql-server/root_password password root'
vagrant@vbbinstubs:~$ sudo debconf-set-selections <<< 'mysql-server-5.5.34 mysql-server/root_password_again password root'
# install versionを確認する場合は下記を実行
vagrant@vbbinstubs:~$ sudo apt-cache showpkg mysql-server

# プロンプトを表示せずにinstall実行
vagrant@vbbinstubs:~$ sudo apt-get -y install mysql-server=5.5.34-0ubuntu0.12.04.1

# インストール確認
vagrant@vbbinstubs:~$ mysql --version
mysql  Ver 14.14 Distrib 5.5.34, for debian-linux-gnu (x86_64) using readline 6.2

# rootでログイン確認
vagrant@vbbinstubs:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.34-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>exit