Mercurial インストール メモ

作業しているとフォルダーが増えてカオスになるので,Mercurial を導入したときのお話.

Mercurial を選んだ理由は名前をみてときめいたから.

インストーラー

http://mercurial.selenic.com/downloads/

does not require admin rights と書いてあるが,Administrators は UAC が発動するようだ.

インストール後,動くか確認.

PS C:\Users\himeno> hg
Mercurial Distributed SCM

basic commands:

 add        add the specified files on the next commit
 annotate   show changeset information by line for each file
 clone      make a copy of an existing repository
 commit     commit the specified files or all outstanding changes
 diff       diff repository (or selected files)
 export     dump the header and diffs for one or more changesets
 forget     forget the specified files on the next commit
 init       create a new repository in the given directory
 log        show revision history of entire repository or files
 merge      merge working directory with another revision
 pull       pull changes from the specified source
 push       push changes to the specified destination
 remove     remove the specified files on the next commit
 serve      start stand-alone webserver
 status     show changed files in the working directory
 summary    summarize working directory state
 update     update working directory (or switch revisions)

use "hg help" for the full list of commands or "hg -v" for details
PS C:\Users\himeno>

設定

hgrc(5) が参考になる.

今回はユーザー名と SSH 接続で使うコマンド,それと文字エンコードなんかを指定した.

[ui]
username = himeno
ssh = "C:\Program Files\PuTTY\plink.exe" -2 -i "C:\Users\himeno\Documents\ひみつかぎ.ppk" -C -l hg
[extensions]
hgext.win32mbcs =
[web]
encoding = UTF-8

Bitbucket に SSH で接続したいんだけど…

動かない….

ググって*1もなかなか出てこないが,どうやら plink.exe が known_hosts に登録するか確認しているものの,それが表示されていないようなのであらかじめ接続して登録しておくことにした.

PS C:\Program Files\PuTTY> .\plink.exe -ssh -2 -l hg -i 'C:\Users\himeno\Documents\ひみつかぎ.ppk' bitbucket.org

もっといい方法があったらおしえてください….

公開鍵を登録しよう

管理画面に設定欄がある.

鍵はコピーして Bitbucket の管理画面に貼り付けると編集する必要がなくなるので楽.

*1:海外ドラマの邦訳で「ググってみよう」と言っていたし,問題ないよね?

MySQL 5.5 インストール メモ

MySQL の導入にかかわるメモがふたつにわかれていたので統合.というわけでちょっとつまづいたお話.

ports

databases/mysql55-serverMySQL 5.5 (2011 年 7 月時点での安定版) がおいてある.ほかにも開発版や古い版などがある.

同様に databases/mysql55-client にはサーバーにアクセスするためのクライアントがおいてある.

いつもどおり ports からインストール.

# pkg_replace -N databases/mysql55-server

起動前の設定

ここから先はこちらも読んだほうがいいとおもいます.

既定では日本語を扱うことを考慮していないため,文字コードの設定を変更する.

ports からインストールした場合,設定ファイルは mysql_dbdir に置かれているファイルを読み込む*1ようになっており*2,既定では /var/db/mysql に設定されている.変えたければ rc.conf で指定してもいい.

/var/db/mysql/my.cnf
[mysqld]
character_set_server = utf8
collation_server = utf8_general_ci
default-character-set=utf8
skip-character-set-client-handshake

default-character-set は非推奨でした.というわけで character_set_server を使いましょう.

skip-character-set-client-handshake はもう mysqld オプションの一覧に載ってないようなので消しておきました.

また,先行するものを除いて,オプション名中のダッシュとアンダースコアは区別されない.

Within option names, dash (“-”) and underscore (“_”) may be used interchangeably. For example, --skip-grant-tables and --skip_grant_tables are equivalent. (However, the leading dashes cannot be given as underscores.)

http://dev.mysql.com/doc/refman/5.5/en/command-line-options.html

起動

まずは rc.conf から.

/etc/rc.conf
mysql_enable="yes"

mysqld_enable じゃない.注意.

マシンを再起動しない場合はとりあえず自分で起動させる.ちなみにこのスクリプトは (初回起動時に) 必要な処理もやってくれるようだ.

# /usr/local/etc/rc.d/mysql-server start
Starting mysql.

起動後の初期設定

初期設定には mysql_secure_installation を使う.

% mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

mysql_secure_installation では root のパスワードを設定したり,ゲスト ユーザーを削除できる.

初期状態では,どのユーザーにもパスワードが割り当てられていない.そのためスーパー ユーザーのパスワードを設定する*3.斜体部分は置き換えるべし.

3 行目ではホスト名*4を指定する.ローカル ホスト以外からの接続は,ローカル ホストからの接続とは区別されるようだ.

% mysql -u user -p

mysql> select host, user from mysql.user;
mysql> set password for 'root'@'localhost' = password('password');
mysql> set password for 'root'@'host_name' = password('password');

また,匿名アカウントを削除した.

mysql> delete from mysql.user where user = '';
mysql> flush privileges;

*1:--defaults-extra-file

*2:http://svnweb.freebsd.org/ports/branches/RELENG_9_1_0/databases/mysql55-server/files/mysql-server.in?view=log

*3:もっといいクエリ文があれば教えてください

*4:1 行目で調べている