运行下面的命令创建名为mydb的数据库
代码如下 | 复制代码 |
createdb mydb |
得到一个错误:psql: FATAL: role "terry" does not exist, terry是我的机器名, 在postgresql数据库中没有名为terry的role, 所以会报出这个错误, 只要加上-U参数来指定一个存在的role就可以了,所以我将上面的命令改为:
代码如下 | 复制代码 |
createdb mydb -U postgres |
又得到一个错误:psql: FATAL: Peer authentication failed for user "postgres",
解决办法如下:
1. 运行下面的命令编辑pg_hba.conf文件
代码如下 | 复制代码 |
sudo gedit /etc/postgresql/9.1/main/pg_hba.conf |
2. 将
代码如下 | 复制代码 |
# Database administrative login by Unix domain socket 改为 # Database administrative login by Unix domain socket |
3. 保存后执行下面的命令重新加载配置文件:
代码如下 | 复制代码 |
sudo /etc/init.d/postgresql reload |
再执行 createdb mydb1 -U postgres , 已经成功的创建了mydb1数据库.
看一老外的文件没译,各位有需要可参考。
I figured I’d share getting setup on my Ubuntu machine.
Installing
sudo apt-get install postgresql
Creating User
createdb book
createuser: could not connect to database postgres: FATAL: role "myusername" does not exist
The bit above can be resolved with the following (replacing myusername for yours)
sudo -u postgres createuser myusername
Shall the new role be a superuser? (y/n) y
Then this should work
createdb book
Installing Extensions
There should be more problems when trying to create the 5 extensions
psql book -c "CREATE EXTENSION tablefunc"
ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/tablefunc.control": No such file or directory
You can fix it by just downloading a package.
sudo apt-get install postgresql-contrib
Downloading the postgresql-contrib packages will give the ability to use the following five commands:
psql book -c "CREATE EXTENSION tablefunc"
psql book -c "CREATE EXTENSION fuzzystrmatch"
psql book -c "CREATE EXTENSION pg_trgm"
psql book -c "CREATE EXTENSION cube"
psql book -c "CREATE EXTENSION dict_xsyn"
And now you should be good to go!
Thanks to the post by Tanner Watson for the CREATE EXTENSION command
恋爱进行时九游版
恋爱进行时九游版是一款以模拟恋爱玩法为核心的角色扮演手游,精
皇室对决fr(Null’s Royale)
皇室对决fr,即皇室战争的私服变态版本,在该版本中玩家能够拥
养了个猫联机版游戏
养了个猫小游戏一个猫咪主题的模拟经营类型的手游,在游戏中我那
模拟山羊收获日小米版
模拟山羊收获日小米版是一个极其魔性的手机游戏,在游戏中玩家将
女配逆袭之素衣
女配逆袭之素衣是一款恋爱养成冒险的一款游戏,可以角色扮演,在