Postgre Init DB and Start
- 使用pg_ctl initdb -D db_files 初始化数据库存
D:\Tools\postgresql-16.3-1-windows-x64-binaries\pgsql>bin\pg_ctl initdb -D db_files
属于此数据库系统的文件宿主为用户 "xxx".
此用户也必须为服务器进程的宿主.
数据库簇将使用本地化语言 "Chinese (Simplified)_China.936"进行初始化.
本地化隐含的编码 "GBK" 不允许作为服务器端的编码.
默认的数据库编码将采用 "UTF8" 作为代替.
initdb: 无法为本地化语言环境"Chinese (Simplified)_China.936"找到合适的文本搜索配置
缺省的文本搜索配置将会被设置到"simple"
禁止为数据页生成校验和.
创建目录 db_files ... 成功
正在创建子目录 ... 成功
选择动态共享内存实现 ......windows
选择默认最大联接数 (max_connections) ... 100
选择默认共享缓冲区大小 (shared_buffers) ... 128MB
选择默认时区 ... Asia/Shanghai
创建配置文件 ... 成功
正在运行自举脚本 ...成功
正在执行自举后初始化 ...成功
同步数据到磁盘...成功
initdb: 警告: 为本地连接启用"trust"身份验证
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
成功。您现在可以用下面的命令开启数据库服务器:
^"D^:^\Tools^\postgresql^-16^.3^-1^-windows^-x64^-binaries^\pgsql^\bin^\pg^_ctl^" -D db_files -l 日志文件 start
- 启动数据库
D:\Tools\postgresql-16.3-1-windows-x64-binaries\pgsql>bin\pg_ctl -D db_files -l db_files\logs start
等待服务器进程启动 ..... 完成
服务器进程已经启动
- 停止数据库
D:\Tools\postgresql-16.3-1-windows-x64-binaries\pgsql>bin\pg_ctl -D db_files -l db_files\logs stop
等待服务器进程关闭 .... 完成
服务器进程已经关闭
- 连接数据库
这种方式创建出来的数据库是用的windows登录的用户名,在使用pgAmin连接时,需要打开 kerberos authentiation