postgres –help

postgres数据库没有启动,用single就可以登录,启动了反而报错

[postgres@ogg2 ~]$ pg_ctl status
pg_ctl: no server running
[postgres@ogg2 ~]$ pg_ctl start
waiting for server to start….2022-10-27 10:25:08.191 CST [2916] LOG:  listening on IPv4 address “0.0.0.0”, port 5432
2022-10-27 10:25:08.191 CST [2916] LOG:  listening on IPv6 address “::”, port 5432
2022-10-27 10:25:08.192 CST [2916] LOG:  listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2022-10-27 10:25:08.193 CST [2916] LOG:  listening on Unix socket “/tmp/.s.PGSQL.5432”
2022-10-27 10:25:08.236 CST [2916] LOG:  redirecting log output to logging collector process
2022-10-27 10:25:08.236 CST [2916] HINT:  Future log output will appear in directory “log”.
  done
server started
[postgres@ogg2 ~]$ postgres –single
2022-10-27 10:26:40.959 CST [2957] FATAL:  lock file “postmaster.pid” already exists
2022-10-27 10:26:40.959 CST [2957] HINT:  Is another postmaster (PID 2916) running in data directory “/data”?

[postgres@ogg2 ~]$ postgres –single -D /home/postgres
postgres: could not access the server configuration file “/home/postgres/postgresql.conf”: No such file or directory
[postgres@ogg2 ~]$ pwd
/home/postgres
[postgres@ogg2 ~]$ postgres –single -D /data
2022-10-27 10:28:52.486 CST [2967] FATAL:  lock file “postmaster.pid” already exists
2022-10-27 10:28:52.486 CST [2967] HINT:  Is another postmaster (PID 2916) running in data directory “/data”?

postgres –single登录进去后psql命令无法使用;退出只能Ctrl+D

[root@ogg2 ~]# su – postgres
[postgres@ogg2 ~]$ which postgres
/usr/pgsql-11/bin/postgres

[postgres@ogg2 ~]$ postgres –help
postgres is the PostgreSQL server.

Options for single-user mode:
   –single           selects single-user mode (must be first argument)
   DBNAME             database name (defaults to user name)
   -d 0-5             override debugging level
   -E                 echo statement before execution
   -j                 do not use newline as interactive query delimiter
   -r FILENAME        send stdout and stderr to given file

[postgres@ogg2 ~]$ postgres –single

PostgreSQL stand-alone backend 11.2
backend> select current_database();
      1: current_database    (typeid = 19, len = 64, typmod = -1, byval = f)
     —-
      1: current_database = “postgres”    (typeid = 19, len = 64, typmod = -1, byval = f)
     —-
backend> \d
2022-10-27 08:54:44.898 CST [2590] ERROR:  syntax error at or near “\” at character 1
2022-10-27 08:54:44.898 CST [2590] STATEMENT:  \d


backend> select count(*) from pg_tables;
      1: count    (typeid = 20, len = 8, typmod = -1, byval = t)
     —-
      1: count = “74”    (typeid = 20, len = 8, typmod = -1, byval = t)
     —-
backend> select count(*) from pg_class;
      1: count    (typeid = 20, len = 8, typmod = -1, byval = t)
     —-
      1: count = “347”    (typeid = 20, len = 8, typmod = -1, byval = t)
     —-


Oracle有个prelim的登录,数据库hang了无法连接时可使用;无法查询数据字典、v$视图和数据信息,均提示not logged on

sqlplus –prelim / as sysdba

[oracle@ogg1 ~]$ sqlplus -prelim / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 27 09:09:39 2022

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

SQL> select count(*) from dba_tables;
select count(*) from dba_tables
*
ERROR at line 1:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

SQL> select count(*) from test.test;
select count(*) from test.test
*
ERROR at line 1:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

SQL> select count(*)from v$tablespace;
select count(*)from v$tablespace
*
ERROR at line 1:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

oracle数据库没启动,-prelim也可以登录

[oracle@ogg1 ~]$ ps -ef | grep pmon
oracle     2598   2572  0 10:52 pts/0    00:00:00 grep pmon
[oracle@ogg1 ~]$ sqlplus -prelim / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 27 10:53:00 2022

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL>           

原文地址:http://www.cnblogs.com/gwgwgw/p/16831841.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性