ERROR: source database "template1" is being accessed by other users
一开始,开发童鞋说他在测试环境没有创建数据库的权限。心想,不对呀,开发环境没有怎么做权限管控,明明给予授权了。
上来一看:
postgres=# CREATE DATABASE "abce" WITH OWNER = "a_admin"
postgres-# ;
ERROR: source database "template1" is being accessed by other users
DETAIL: There is 1 other session using the database.
原来不是权限的问题!
查看一下,谁在使用template1:
postgres=# select * from pg_stat_activity where DATNAME = 'template1';
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_
start | state_change | wait_event_type | wait_event | state | backend_xid | backend_xmin |
query | backend_type
-------+-----------+-------+----------+-----------+------------------+--------------+-----------------+-------------+------------------------------+------------+----------------
---------------+-------------------------------+-----------------+------------+-------+-------------+--------------+-------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------+----------------
1 | template1 | 23498 | 16384 | a_admin | NAVICAT | xx.xx.xx.xxx | | 61664 | 2019-10-08 16:15:06.46307+08 | | 2019-10-08 16:1
5:16.542588+08 | 2019-10-08 16:15:16.545124+08 | Client | ClientRead | idle | | | SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcrea
tedb, rolcanlogin, rolconnlimit, rolvaliduntil, rolconfig, oid , pg_catalog.shobj_description(oid, 'pg_authid') AS comment FROM pg_roles | client backend
(1 row)
将查出的pid kill掉
postgres=# SELECT pg_terminate_backend( 23498);
pg_terminate_backend
----------------------
t
(1 row)
也可以使用一条语句,直接将使用template1的会话kill掉:
select pg_terminate_backend(pid) from pg_stat_activity where DATNAME = 'template1';
然后再执行数据库创建语句即可!
ERROR: source database "template1" is being accessed by other users的更多相关文章
- ERROR: database "db" is being accessed by other users
执行DROP DATABASE testdb;的时候提示: ERROR: database "testdb" is being accessed by other users DE ...
- Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for …
编译通过并且运行web成功后,访问的页面不需要连接数据库,不牵扯到反射调用实体类就不会报错, 报错内容如下: [WARNING] org.springframework.web.util.Nested ...
- Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名
今天调试程序是遇到了,下面的一个问题.我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的 ...
- postgresql 删除库的时候报错database "temp_test_yang" is being accessed by other users
删除库的时候报错 ERROR: database "temp_test_yang" is being accessed by other usersDETAIL: There ar ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manu
这个是sql 语句 错误 仔细检查 SQL语句是否写错了 org.apache.ibatis.exceptions.PersistenceException: ### Error queryi ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent succ
数据库 没有开启 连接失败 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause ...
- 一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException问题排查过程
先说结论: 因为在表设计中有一个商品描述字段被设置为desc,但desc是mysql中的关键字,如select id,name,desc,price from product;这条sql语句在查询时的 ...
- mybatis <fireach> 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause:
<select id="getUserIn" parameterType="QueryVo" resultMap="userMap"& ...
- Create schema error (unknown database schema '')
Andrey Devyatka 4 years ago Permalink Raw Message Hi,Please tell me, can I use the static library in ...
随机推荐
- Walle实现自动发布
walle是啥?能干啥?有啥用?这些我都不会去一一道来,如果你还没有明白前面提出的三个问题就不用往下看了,这里这回将walle安装了怎么去使用.如果都要面面俱到不是一两篇博客可以解决的问题,如果希望将 ...
- 小程序的openid和公众号的openid是否一致
早期的产品只用了公众号,没有注册开放平台(没有unionid).然后现在需要上线小程序,这种情况下,企业是同一个企业的,但是公众号的openid和小程序的openid是否一致呢? 我来回答你这个问题: ...
- php框架路由美化后提示No input file specified
此问题出现在.htaccess上 Apache按如下代码修改即可: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond % ...
- 【Flask】 python学习第一章 - 5.0 模板
jinjia2 模板 python实现 flask 内置语言 参照Djago实现 设置模板文件夹 设置模板语言 jinja2 demo6_template.html ----> 从代码渲染 ...
- Python标准库-数字的处理函数(math模块)
Python标准库-数字的处理函数(math模块) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. #!/usr/bin/env python #_*_conding:utf-8_* ...
- HTML&CSS基础-内联样式和内部样式表
HTML&CSS基础-内联样式和内部样式表 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.CSS(Cascading Style Sheets)简介 层叠样式表(Cas ...
- c风格的字符串
c风格的字符串的标注库 #include <cstring> 使用c 风格的字符串,牢记,其必须以null为结束标志 如 char ca[]={'c','+','='}; cout< ...
- 微信小程序-数组操作
Page({ data: { list:[{ id:, name:'芒果', count: },{ id:, name:'香蕉', count: }, }] } }) 向前插入数据 //要增加的数组 ...
- Linux代理服务器使用
1. 介绍 代理(即网络代理)是一种特殊的网络服务, 允许一个网络终端(客户端)通过这个服务与另一个终端(服务器)进行非直接连接,从而提供服务. 其中, 提供代理的网络终端称为代理服务器(Proxy ...
- postgres高可用学习篇二:通过pgbouncer连接池工具来管理postgres连接
安装pgbouncer yum install libevent -y yum install libevent-devel -y wget http://www.pgbouncer.org/down ...