postgresql的自动化脚本
请帮我在Ubuntu上安装postgresql后如何运行postgresql的自动化脚本? 我需要使用它之前自动化数据库准备(创build表,插入数据,更改权限)。
我需要与用户的当前权利。 例如,我有唯一的用户admin_ubuntu。 他拥有运行psql的全部权利。 所有脚本都被写入,但是我怎样才能运行脚本? 通常,我需要编辑configuration(我相信,/etc/postgresql/9.1/main/pg_hba.conf)。 但我不想这样做。
所以,我需要的仅仅是运行SQL,这将使很多事情。 我怎样才能运行它? 问题是我需要做很多事情来允许当操作系统完美(空)时运行SQL。
每当Ubuntu将被安装时,它将被制作。
你应该能够运行shellconfiguration – 以下是你可以做的事情的例子:
# creating user sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'password';" # creating new db if needed .. might need 2 (dev/test) createdb -U vagrant mydevdb # if you have more complex things you'll need to put that in a create_db.sql file and run the script as sudo -u postgres psql < create_db.sql
create_db.sql文件可以包含任何CREATE TABLE
语句