在一個網(wǎng)站中,django_session表很容易就突破了200萬條記錄,后來定期清理過期的session,也會保持在100多萬條記錄。數(shù)據(jù)庫是mysql,后果是django_session表不定期損壞,每次都得修復(fù)或者干脆truncate。所以打算弄弄postgresql。
os 是ubuntu 10.04,使用sudo apt-get install postgres,將會安裝8.4版本的postgres。安裝完之后,執(zhí)行psql,就報了一個錯:
FATAL:? Ident authentication failed for user
無法驗證用戶
google了一下,需要使用postgres帳號進行管理,su postgres即可。
在網(wǎng)上有一個中文文檔,非常有幫助, http://man.chinaunix.net/database/postgresql_8.0_CN/ .
創(chuàng)建用戶:在shell下直接執(zhí)行createuser 命令,或者在psql下執(zhí)行CREATE USER name;
更改用戶密碼:alter user username1 with password ‘new password’;
導出數(shù)據(jù):
pg_dump -b dbame | gzip > dbname.gz
恢復(fù)數(shù)據(jù):
createdb dbname gunzip -c dbname .gz | psql dbname
更改數(shù)據(jù)庫所有者:
alter database dbname owner to usename;
在/etc/postgres/目錄下,修改pg_hba.conf,加上用戶訪問數(shù)據(jù)庫的權(quán)限
登錄命令:
psql -U usename -W -d dbname
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
