今更MySQL入門
MongoDBもいいけどそもそもRDB使えないと困るのでMySQLを……(実はまともに扱えるRDBがひとつもない)
環境:Ubuntu 10.04.3 LTS 64bit
インストール
本当はソースから入れてみたかったけど。
$ sudo apt-get install -y mysql-server
インストール中にConfiguring mysql-server-5.1が表示されるので、MySQLのrootパスワードを入力する。
インストール後に一応(?)再起動した。
$ sudo shutdown -r now
MySQLが起動しているか確認
まあ、aptから入れたんだししてるんだろうけど。
てかUbuntuもserviceコマンド入ったんだねえ。
RHELはserviceで、Ubuntuは/etc/init.d/xxxとか切り替えて叩くのが面倒だったなあ。そういう苦労もしなくて済む。
$ sudo service mysql status
Ubuntuの方は最後にdを付けなくていいのか。
あと--status-allもちゃんとあるみたい。
起動していなかった場合は
$ sudo service mysql start
で起動させる。
コマンドラインツールからログイン
$ mysql -u root -p
-uはユーザを指定、-pはパスワード入力するよー、ってオプションらしい。
-uと同じく、-pのあとにパスワードを打つとそのまま直に入れるぽい。非推奨だろうけど。
入るといろいろ表示されて入力待ちになる。
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 45 Server version: 5.1.61-0ubuntu0.10.04.1 (Ubuntu) Copyright (c) 2000, 2011, 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>
終了は
mysql> exit Bye
でOKです。
続くのかなこれ。