Java 如何在windows中作为服务运行PostgreSQL?
我在Windows7 32位操作系统中安装了postgreSQL二进制文件;我可以从cmd启动服务器,但无法将其作为windows服务运行。 这是我尝试手动启动服务时遇到的错误:Java 如何在windows中作为服务运行PostgreSQL?,java,postgresql,windows-services,Java,Postgresql,Windows Services,我在Windows7 32位操作系统中安装了postgreSQL二进制文件;我可以从cmd启动服务器,但无法将其作为windows服务运行。 这是我尝试手动启动服务时遇到的错误: "The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs" 我所需要做
"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"
我所需要做的就是;在启动到windows之后,当我双击java应用程序时,我需要平稳运行我的应用程序,而不会出现任何数据库错误。我无法执行此操作,因为postgreSQL未作为windows服务运行
我在windows事件查看器中找到了此选项:
"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"
我在谷歌上搜索了一下,但找不到答案。问题解决了
windows服务文件中的数据目录路径错误
因此,我从该方法中删除服务文件:
1)运行Regedit或Regedt32。
2)进入注册表项“HKEY\U LOCAL\U MACHINE/SYSTEM/CurrentControlSet/Services”
3)查找要删除的postgreSQL服务并将其删除。
4)重新启动计算机。
之后,打开cmd(以管理员身份运行)转到postgreSQL bin目录并运行此命令以创建新的windows服务:
pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "C:/Program Files/postgresql/pgsql/bin/pgsql/data" -w
这对我有用。希望这会有所帮助
postgres无法访问服务器配置文件
“C:/Windows/system32/pgsql/data/postgresql.conf”:没有此类文件或
目录
看起来您的工作目录是C:\Windows\system32
,您正在那里运行postgres,它查找data/postgresql.conf
尝试更改工作目录或指定
-dc:\path\to\my\data
这是普通用户的注意事项。如果使用官方安装程序,它应该有内置服务
services.msc
使用默认的postgres安装程序,它应该以自动启动模式作为服务安装。你试过重新安装postgres吗?我在另一台计算机上试过,但是我得到了同样的错误。你能告诉我如何卸载postgreqsl二进制文件吗?转到你的postgres安装目录并运行“uninstall postgresql.exe”,我想有些文件丢失了;我从windows事件查看器获得了一些信息;我已经更新了关于它的问题。你是在你的计算机上安装了postgres还是只是复制了文件?