MySQLのセットアップ

mysql_install_dbを実行しMySQLのシステムテーブルを作成する。

www# /usr/local/bin/mysql_install_db
Installing MySQL system tables...
080114 2:51:01 [Note] Plugin 'InnoDB' disabled by command line option
080114 2:51:01 [Warning] /usr/local/libexec/mysqld: unknown option '--loose-skip-ndbcluster'

OK
Filling help tables...
080114 2:51:01 [Note] Plugin 'InnoDB' disabled by command line option
080114 2:51:01 [Warning] /usr/local/libexec/mysqld: unknown option '--loose-skip-ndbcluster'

OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h xxxxxx.org password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
www#
www# cd /var/db
www# chown -R mysql:mysql mysql

/var/db/mysqlが作成されていることを確認する。

www# cd /var/db
www# ls
dhclient.leases entropy ipf locate.database mountdtab mysql pkg portaudit ports
www#
www#
www# cd mysql
www# ls
mysql test
www# cd mysql
www# ls
columns_priv.MYD general_log.frm host.MYI servers.MYD time_zone_leap_second.frm
columns_priv.MYI help_category.MYD host.frm servers.MYI time_zone_name.MYD
columns_priv.frm help_category.MYI ndb_binlog_index.MYD servers.frm time_zone_name.MYI
db.MYD help_category.frm ndb_binlog_index.MYI slow_log.CSM time_zone_name.frm
db.MYI help_keyword.MYD ndb_binlog_index.frm slow_log.CSV time_zone_transition.MYD
db.frm help_keyword.MYI plugin.MYD slow_log.frm time_zone_transition.MYI
event.MYD help_keyword.frm plugin.MYI tables_priv.MYD time_zone_transition.frm
event.MYI help_relation.MYD plugin.frm tables_priv.MYI time_zone_transition_type.MYD
event.frm help_relation.MYI proc.MYD tables_priv.frm time_zone_transition_type.MYI
func.MYD help_relation.frm proc.MYI time_zone.MYD time_zone_transition_type.frm
func.MYI help_topic.MYD proc.frm time_zone.MYI user.MYD
func.frm help_topic.MYI procs_priv.MYD time_zone.frm user.MYI
general_log.CSM help_topic.frm procs_priv.MYI time_zone_leap_second.MYD user.frm
general_log.CSV host.MYD procs_priv.frm time_zone_leap_second.MYI
www#

/etc/rc.confの設定

/etc/rc.confに下記の行を追加する。
この設定でサバーの起動時にmysqlが起動する。

mysql_enable="YES"


サーバーを再起動しMySQLが起動するか確認する。

www# ps -aux | grep mysql
mysql 429 0.0 0.3 1664 1200 con- I 3:08AM 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/xxxxx.pid
mysql 474 0.0 5.3 41376 24108 con- S 3:08AM 0:00.28 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --pid-file=/var/db/mysql/xxxxx.pid
mysql 475 0.0 0.2 1244 804 con- I 3:08AM 0:00.00 sed -e s/^[0-9]\\{6\\} [0-9:]\\{8\\} *//
mysql 476 0.0 0.1 1204 644 con- I 3:08AM 0:00.00 logger -i -t mysqld -p daemon.error
www#

mysqld_safeとmysqldが起動している。
多分、これでOK。

MySQLのrootのパスワードを設定

下記のコマンドでMySQLのrootのパスワードを設定する。
'new-password'には任意の文字列を設定する。

/usr/local/bin/mysqladmin -u root password 'new-password'

mysql DBに接続できることを確認

mysql DBに接続

www# mysql -u root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.20-beta FreeBSD port: mysql-server-5.1.20

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

mysql>

テーブル一覧を表示させてみる。

mysql> SHOW TABLES ;

                                                        • +
Tables_in_mysql
                                                        • +
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
                                                        • +

23 rows in set (0.00 sec)

mysql>