前人未踏の領域へ Androidアプリ開発編

Androidアプリ開発に関する調査メモ置き場。古い記事にはアプリ以外も含まれます。

debconfを使ったインストール

自動インストールなどでMySQLのrootパスワード入力を求められないために

シェル作成

説明上、root_password パスワードは「root」にしてある。適宜変更して使う。

$ vi mysql-install.sh
mysql-install.shの編集
#!/usr/bin/env bash
echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections
aptitude -y install mysql-server

実行

$ chmod 755 mysql-install.sh
$ sudo ./mysql-install.sh

確認

vagrant@vagrant-ubuntu-trusty-64:~$ mysql -u root -p
Enter password: //rootと入力
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, 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> 

おまけ MySQLUbuntuからアンインストールする

上記シェル作成中に何度か削除する必要が発生したので。

$ vi mysql-remove.sh
mysql-remove.shの編集
#!/usr/bin/env bash
aptitude -y purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
rm -rf /var/lib/mysql/mysql
rm -rf /etc/mysql