PostgreSql 常用命令
Installationhttps://github.com/railscasts/337-capistrano-recipes/blob/master/blog-after/config/recipes/postgresql.rbhttp://whatcodecraves.com/articles/2008/02/05/setup-rails-with-postgresql sudo add-apt-repository ppa:pitti/postgresql -y sudo apt-get -y update sudo apt-get -y install postgresql libpq-dev sudo -u postgres psql -c "create user xxx with password xxx;" sudo -u postgres psql -c "create database xxx owner xxx;" drop database: psql -U luna -d xxx -W -c "drop database xxx" [编辑]Postgres数据库常用操作命令 psql连接数据库: 删除数据库: 或者: 创建数据库(luna用户作为拥有者): 查看数据库中的所有表: psql登录进去后,执行 执行表users信息: 修改数据库用户的密码: [编辑]Backup & Restoreofficial backup:http://www.postgresql.org/docs/9.1/static/backup-dump.html#BACKUP-DUMP-ALL File System Level Backup can only be done while database is down,in order to ensure the integrity and up-to-date for backups. READ:http://www.postgresql.org/docs/9.1/static/backup-file.html example crontab backup: 26 * * * * sudo -u postgres pg_dumpall --clean > /tmp/db_dump_all.pgdump example restore: sudo -u postgres pgsql -f /tmp/db_dump_all.pgdump osx install,create database and user http://blog.willj.net/2011/05/31/setting-up-postgresql-for-ruby-on-rails-development-on-os-x/ 更有封装好的shell command sudo -u postgres + createuser -P laoban #创建用户带密码 Enter 后输入密码 dropuser 'xxx' #删除用户 删除数据库
dropdb demo创建数据库 并分配给指定用户 createdb -O username database_name 导入数据库
psql dbname < infile (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |