UbuntuにMySqlをインストール
apt-get でインストール。
takatoh@nightschool $ sudo apt-get install mysql-server
途中で root ユーザーのパスワードを入力するように促されるので、入力する(2回)。
バージョンの確認。
takatoh@nightschool $ mysql --version
mysql Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using readline 6.3
/etc/mysql に移動して、設定ファイル my.cnf に文字コードなど追記。…の前にバックアップをとっておく。
takatoh@nightschool $ sudo cp my.cnf my.cnf.orig
takatoh@nightschool $ sudo vim my.cnf
以下を追記。
[client]
default-character-set = utf8
[mysqld]
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8
MySQL を再起動。
takatoh@nightschool $ sudo service mysql restart
mysql stop/waiting
mysql start/running, process 30969
MySQL にログイン。
takatoh@nightschool $ mysql -u root -p
ステータスを確認。
mysql> status
--------------
mysql Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using readline 6.3
Connection id: 36
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 1 min 48 sec
Threads: 1 Questions: 109 Slow queries: 0 Opens: 171 Flush tables: 1 Open tables: 41 Queries per second avg: 1.009
--------------
うまくいってるっぽい?
プロセスの確認。
takatoh@nightschool $ ps aux | grep mysqld
mysql 30969 0.0 1.0 484440 42984 ? Ssl 21:44 0:00 /usr/sbin/mysqld
takatoh 31111 0.0 0.0 16904 932 pts/4 S+ 21:47 0:00 grep --color=auto mysqld
参考にしたページ:
