$ sudo port install mysql55-server
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
$ sudo chown -R atsushi /opt/local/var/db/mysql55/ $ sudo chown -R atsushi /opt/local/var/run/mysql55/
$ /opt/local/lib/mysql55/bin/mysqld
$ /opt/local/lib/mysql55/bin/mysqladmin -u root password 'mypassword'
$ /opt/local/lib/mysql55/bin/mysqladmin shutdown -u root -p Enter password: mypassword
$ /opt/local/etc/mysql55/ $ sudo mv my.cnf my.cnf.original $ touch my.cnfインストーラーが作ったものを退避して、空の my.cnf を作る。
# Use default MacPorts settings !include /opt/local/etc/mysql55/macports-default.cnf
[mysqld] # skip-networking so multple mysql server ports can be loaded # without each competing for port 3306. skip-networking
$ /opt/local/lib/mysql55/bin/mysqld
$ /opt/local/lib/mysql55/bin/mysqladmin shutdown --user=root --password=mypassword
http://dev.mysql.com/downloads/workbench/5.2.html
create database warehouse; grant all privileges on warehouse.* to appuser@localhost identified by 'apppassword';
CREATE TABLE `warehouse`.`customer` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(255) NOT NULL ,
`address` VARCHAR(1024) ,
PRIMARY KEY (`id`) );
CREATE TABLE `warehouse`.`item` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(255) NOT NULL ,
`price` BIGINT ,
`stock` BIGINT ,
PRIMARY KEY (`id`) );
CREATE TABLE `warehouse`.`order` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`customer_id` BIGINT NOT NULL ,
`item_id` BIGINT NOT NULL ,
`amount` BIGINT NOT NULL,
`shipdate` DATETIME NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`customer_id`) references customer(`id`),
FOREIGN KEY (`item_id`) references item(`id`) );