首页 > 数据库 >PostgreSQL的单用户模式

PostgreSQL的单用户模式

时间:2022-10-27 12:55:23浏览次数:48  
标签:count 10 27 PostgreSQL postgres 模式 单用户 2022 CST


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>           


标签:count,10,27,PostgreSQL,postgres,模式,单用户,2022,CST
From: https://www.cnblogs.com/gwgwgw/p/16831841.html

相关文章

  • 设计模式之桥接模式
    概述桥接模式是一种很实用的结构型设计模式。如果软件系统中某个类存在两个独立变化的维度,通过该模式可以将这两个维度分离出来,使两者可以独立扩展,让系统更加符合单一职责......
  • preg_replace /e 模式下的代码执行问题
    preg_replace/e模式下的代码执行问题preg_replace在/e模式下存在代码执行问题这里借用例题分析functioncomplex($re,$str){returnpreg_replace(......
  • 简单工厂模式
    1.利用面向对象思想实现1.1面向对象的好处通过封装、继承和多态把程序的耦合性降低,用设计模式使得程序更加灵活,容易修改,并易于复用。1.2简单工厂模式静态方法模式(因......
  • linux LVS的DR模式实现
    架构图:环境:一台:客户端eth0:仅主机192.168.10.6/24GW:192.168.10.200一台:ROUTEReth0:NAT 10.0.0.200/24eth1:仅主机192.168.10.200/24启用IP_FORWARD一......
  • pg_auto_failover 高可用PostgreSQL
    1、从软件包安装pg_auto_failover#Addtherepositorytoyoursystemcurlhttps://install.citusdata.com/community/rpm.sh|sudobash#Installpg_auto_failover......
  • javascript编程单线程之异步模式Asynchronous
    异步模式Asynchronous不会等待这个任务结束才开始执行下一个任务,开启之后立即执行下一个任务,后续逻辑一般会通过回调函数的方式定义,异步模式对js非常重要,没有异步任务单线......
  • javascript编程单线程之异步模式Asynchronous
    异步模式Asynchronous不会等待这个任务结束才开始执行下一个任务,开启之后立即执行下一个任务,后续逻辑一般会通过回调函数的方式定义,异步模式对js非常重要,没有异步任务单......
  • 适配器模式
    适配器模式 将一个类的接口转换成客户希望的另外一个接口,使得原本由于接口不兼容而不能一起工作的那些类能一起工作。适配器模式分为类结构型模式和对象结构型模式两种,前......
  • 建造者模式
    建造者模式(生成者模式)指将一个复杂对象的构造与它的表示分离,使同样的构建过程可以创建不同的表示,这样的设计模式被称为建造者模式。它是将一个复杂的对象分解为多个简单的......
  • Java设计模式 —— 代理模式
    15代理模式15.1代理模式概述ProxyPattern:给某一个对象提供一个代理或占位符,由代理对象来控制对原对象的访问。代理对象是客户端和目标对象的之前的桥梁,它接收来......