FreeBSDでMySQL4.1のインストールと設定


インストール

  • デフォルトだと /var/db/mysql にデータベースファイルが置かれてしまうので、/usr/local/mysql に置くようにする。
  • portsからインストールするとユーザーmysqlが自動で作られる。

  • 日本語を使えるようにする。デフォルトはUTF-8にする。

portsでインストール

cd /usr/ports/databases/mysql41-server
make WITH_CHARSET=utf8 WITH_XCHARSET=all
make install

portinstallでインストール

/usr/local/etc/pkgtools.confの

MAKE_ARGS = {
}

MAKE_ARGS = {
    'databases/mysql41-*'   => 'WITH_CHARSET=utf8 WITH_XCHARSET=all',
}

を追加して

portinstall databases/mysql41-server

自動起動設定

ディレクトリ「/usr/local/mysql」を作って、オーナーを「mysql」にする。

mkdir /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql

起動設定

vi /etc/rc.conf
mysql_enable="YES"
mysql_dbdir="/usr/local/mysql"

一度起動してみる

/usr/local/etc/rc.d/mysql-server.sh start

インストール後の設定

rootユーザーのパスワードを設定する

mysqladmin -u root password ********

passwordが必要ないユーザーが登録されているので削除する。

# mysql -u root -p
Enter password: passwordを入力
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.23.49

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> delete from user where password = ""\g
Query OK, 3 rows affected (0.01 sec)

mysql> flush privileges\g
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

コメントを残す

Some HTML is OK