运行下面的命令创建名为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
疯狂医院达什医生中文版(Crazy Hospital)
疯狂医院达什医生最新版是一款医院模拟经营类游戏,逼真的场景画
宝宝庄园官方版
宝宝庄园官方版是一款超级经典好玩的模拟经营类型的手游,这个游
桃源记官方正版
桃源记是一款休闲娱乐类的水墨手绘风格打造的模拟经营手游。玩家
长途巴士模拟器手机版
长途巴士模拟器汉化版是一款十分比真好玩的大巴车模拟驾驶运营类
房东模拟器最新版2024
房东模拟器中文版是一个超级有趣的模拟经营类型的手游,这个游戏