FreeBSD 9.3 RELEASE - MySQL
「MySQL」の詳細については WikiPedia をご参照ください。
- 1. ports install
- 2. コンフィグレーションファイルの設定
- 3. 起動
- 4. ルートユーザへのパスワード設定
1. ports install
2014年8月8日現在の MySQL の安定板はバージョン 5.6 です。
/usr/ports/databases/mysql56-client
/usr/ports/databases/mysql56-server
2. コンフィグレーションファイルの設定
起動スクリプトは /usr/local/etc/rc.d/mysql-server に作成されてその中を見ると、コンフィグレーションファイルの置き場所は /var/db/mysql となっているのですが、2014年8月8日現在、インストール直後に何故か /usr/local の直下に my.cnf というコンフィグレーションファイルが作成されていますので
> cd /usr/local/
> mv /usr/local/my.cnf /var/db/mysql/.
で移動させておいて編集します。
最低限やっておくこととして、デフォルトの文字コードが latin1 になっていますので日本語の文字コードにしたいところです。仮に utf8 にするとします。文字コードの設定方法はバージョンによって違うので、これはあくまでも PHP5.6 の方法です。
my.cnf に以下の記述を加えます。
[mysqld]
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
[client]
default-character-set = utf8
[mysqldump]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld] はデフォルトで記述されているセクションなので、二重書きにならないように注意してください。
3. 起動
/etc/rc.conf に
mysql_enable="YES"
の1行を加えて
> /usr/local/etc/rc.d/mysql-server start
でサーバを起動できます。
4. ルートユーザへのパスワード設定
最低限のセキュリティのためにパスワードを設定しておきます。
> mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.20 Source distribution
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> SET PASSWORD FOR root@localhost=PASSWORD('...'); "← '...'の箇所にパスワードを入力します"
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
|
|