Postgresql 创建数据库 [英] Postgresql creating database
问题描述
好吧,我在 Windows 7 上安装了最新的 postgreql 数据库.
Well I installed the latest postgreql database on my Windows 7.
现在我正在尝试通过 psql.exe 命令行创建数据库
Now I'm trying to create a database via the psql.exe command line
当我打开它时,它说
psql: FATAL: database "Jansu" does not exist
所以我在某处读到,当没有指定数据库时,它会尝试使用我的用户名或其他内容查找数据库.
So I read somewhere, that when no database is specified, it tried to find database with my username or something.
无论如何..当我无法访问命令行时,我该如何创建新数据库.
Anyways..how do i create a new database, when I can't access the commandline.
推荐答案
阅读 psql 语法一>.您可以指定数据库、用户和其他参数.如果是全新安装,则应该有一个默认数据库postgres",您可以连接到该数据库.
Read psql syntax. You can specify database, user and other parameters. If it's a new installation, there should be a default database 'postgres', you can connect to that one.
psql -U postgres postgres
(在 Unix 环境中,您可能需要添加 -h localhost
以强制 TCP 连接,否则它会尝试使用 Unix 域套接字,这可能不适用于除postgres
用户.)
(In Unix environments you might need to add -h localhost
in order to force a TCP connection, otherwise it'd try to use Unix-domain sockets, which might not work for other than the postgres
user. )
您可以从那里创建数据库,也可以从命令行使用 createdb
You can create databases from there, or from the command line with createdb
这篇关于Postgresql 创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!