mac安装postgresql

brew install postgresql

查看版本

pg_ctl -V   

psql --version

初始化数据库

initdb /Volumes/SSD4T/pgdata -E utf8

启动数据库

postgres -D /usr/local/var/postgres
brew services start postgresql
pg_ctl -D /usr/local/var/postgres start

 

#设成开机启动 PostgreSQL:
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

 

#创建一个 PostgreSQL 用户
$ createuser username -P

#创建数据库
$ createdb dbname -O username -E UTF8 -e

#连接数据库
$ psql -U username -d dbname -h 127.0.0.1

 

#连接数据库
$ psql -U username -d dbname -h 127.0.0.1
\l
列数据库
\d
列出表

 

 

create user uran with password 'test';
create database uran_db owner uran;
grant all privileges on database uran_db to uran;

 

posted @ 2025-05-26 14:49  meetrice  阅读(121)  评论(0)    收藏  举报