ubuntu中用命令创建数据库

# switch to postgres account
sudo su postgres
  
# create a new postgres login: jetty; and set the password to jetty
# since most of our database dump has jetty as the user
createuser -P -d -a -e jetty
#password jetty
 
# create a new postgres login: logintext;
# this is also due to database dump file; SHOULD HAVE DUMP DATABASE WITH -U option;
createuser -P -d -a -e logintext
# create a new empty database
# set the password to jetty (to be consistent with application setting - only for DEV/TESTING)
createdb test -O jetty
  
# grant permission to jetty
psql
#click Enter on keyboard
GRANT all on database test to jetty;
#click Enter on keyboard
\q
#click Enter on keyboard
 
# restore database option1
psql test </tmp/<dumpfile>
 
# restore database option2
psql -d test -t ~/tmp/<dumpfile>
 
# restore database option 3
# psql -d <database> U <username> -f <filename>
psql -d test -U logintest -f demo.test.s83.0.sql
 
# return to your own account
exit

 

posted @ 2017-02-27 16:20  growthofmonkey  阅读(307)  评论(0编辑  收藏  举报