読者です 読者をやめる 読者になる 読者になる

IT分からんわ~_~;

IT色々お勉強中のブログ

postgres

admins-MacBook-Pro% initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "hoge".
This user must also own the server process.

The database cluster will be initialized with locale "ja_JP.UTF-8".
initdb: could not find suitable text search configuration for locale "ja_JP.UTF-8"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".
admins-MacBook-Pro% postgres -D /usr/local/var/postgres
LOG:  database system was shut down at 2016-02-12 19:25:29 JST
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
admins-MacBook-Pro% unlink LaunchAgents
admins-MacBook-Pro% ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
/Users/hoge/Library/LaunchAgents/homebrew.mxcl.postgresql.plist -> /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist
admins-MacBook-Pro% launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
/usr/local/Cellar/postgresql/9.4.5_2/homebrew.mxcl.postgresql.plist: Operation already in progress

pg_ctl: server does not shut down
postgresqlでdescしたいとき
\d accounts

select column_name,data_type from information_schema.columns where table_name ='table_name';
データベース一覧

$ psql -l
ユーザー一覧表示

# \du
データベース一覧

# \l
他のデータベースに接続し直す

# \connect db_name
# create user username;
CREATE ROLE
# create database db_name;
CREATE DATABASE
[git][* master]:~/projects/hoge/ psql postgres
psql (9.4.5)
Type "help" for help.

postgres=# CREATE DATABASE hogehoge_development;

その他コマンド

sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo launchctl start homebrew.mxcl.dnsmasq
sudo launchctl stop homebrew.mxcl.dnsmasq