简体   繁体   English

Postgres - 从Mac终端列出数据库

[英]Postgres - list databases from Mac terminal

I'm experienced with MySQL, but I've just started to work with Postgres - from the terminal on my Mac, how can I see the list of existing Postgres databases using the psql command? 我对MySQL很有经验,但我刚刚开始使用Postgres - 从Mac上的终端,如何使用psql命令查看现有的Postgres数据库列表?

I checked the documentation and I've seen this issue brought up here - https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql , where the accepted solution is to simply type psql \\l , and that makes sense to me... however, when I try this, I get the error 我检查了文档,我看到这个问题出现在这里 - https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql ,其中接受的解决方案是简单地键入psql \\l ,这对我有意义...但是,当我尝试这个时,我得到了错误

psql: FATAL: database "l" does not exist

but I am logged in to Postgres - if I type psql DATABASE_NAME , no problem, I get into the database... this was an issue for me recently because I couldn't remember the name of the database that I wanted to work on. 但我登录到Postgres - 如果我键入psql DATABASE_NAME ,没问题,我进入数据库...这对我来说是一个问题,因为我记不起我想要处理的数据库的名称。 I went into another table (the name of which I did remember), then used the \\l command to see my databases and connected to the DB I needed, but I'd much rather just be able to see a list without having to first connect to a database. 我进入另一个表(我记得的名字),然后使用\\l命令查看我的数据库并连接到我需要的数据库,但我更愿意只能看到一个列表而不必先连接到数据库。 How can I do that? 我怎样才能做到这一点?

感谢@MichałSznurawa指出我正确的方向 - 从Mac终端,使用psql -l ,而不是psql \\l做的伎俩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM