Mac上使用homebrew安装PostgreSql
2023-09-14 08:56:51 时间
$ initdb /usr/local/var/postgres The files belonging to this database system will be owned by user "june". This user must also own the server process. The database cluster will be initialized with locale "zh_CN.UTF-8". The default database encoding has accordingly been set to "UTF8". initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8" The default text search configuration will be set to "simple". Data page checksums are disabled. creating directory /usr/local/var/postgres ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB creating configuration files ... ok creating template1 database in /usr/local/var/postgres/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgSQL server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections 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. Success. You can now start the database server using: postgres -D /usr/local/var/postgres pg_ctl -D /usr/local/var/postgres -l logfile start
配置开机登陆(可选):
$ mkdir -p ~/Library/LaunchAgents $ cp /usr/local/Cellar/postgresql/9.3.5_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ $ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
手动启动 postgresql
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
查看状态:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log status
停止:
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop -s -m fast
查看进程:
$ ps auxwww | grep postgres june 56126 0.0 0.0 2432772 644 s000 S+ 5:01下午 0:00.00 grep postgres june 56058 0.0 0.0 2467360 584 ?? Ss 5:00下午 0:00.00 postgres: stats collector process june 56057 0.0 0.0 2611808 1744 ?? Ss 5:00下午 0:00.00 postgres: autovacuum launcher process june 56056 0.0 0.0 2611676 696 ?? Ss 5:00下午 0:00.00 postgres: wal writer process june 56055 0.0 0.0 2611676 944 ?? Ss 5:00下午 0:00.01 postgres: writer process june 56054 0.0 0.0 2611676 756 ?? Ss 5:00下午 0:00.00 postgres: checkpointer process june 56044 0.0 0.2 2611676 14096 s000 S 5:00下午 0:00.02 /usr/local/Cellar/postgresql/9.3.5_1/bin/postgres -D /usr/local/var/postgres
创建用户和数据库:
#createuser will prompt you for a password, enter it twice. $ createuser -P test $ createdb -Otest -Eutf8 test_db $ psql postgres=# GRANT ALL PRIVILEGES ON test TO test; postgres=# \q
进入命令行模式:
$ psql -U test test_db -h localhost -W
如果出现 FATAL: Ident authentication failed for user,是因为:
This is because by default PostgreSQL uses ‘ident’ authentication i.e it checks if the username exists on the system. You need to change authentication mode to ‘trust’ as we do not want to add a system user. Modify the settings in “pg_hba.conf” to use ‘trust’ authentication.
请修改 /usr/local/var/postgres/pg_hba.conf 为:
host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
安装 pgadmin,下载地址:http://www.pgadmin.org/download/macosx.php
$ brew uninstall postgres
如果配置了开机登陆:
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist $ rm -rf ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Winsows Server 2019 安装 PostgreSQL 环境准备 windows server 2019 镜像文件,官网地址 =》Windows Server 2019 | Microsoft postgresql 12.x for windows,官网地址=》PostgreSQL: The world s most advanced open source database 准备一个满足以上条件的服务器;(物理机,VM 均可)以上环境中安装 windows server 2019 的环节省略,...
【PostgreSQL】入门学习笔记(包括安装、环境与参数配置、故障排查以及备份还原等) 以下内容为前几天在备考PostgreSQL入门考试时候做的笔记,经过了全职的两天的奋战与实验,并最终顺利通过了PCA初级认证考试。现在把我学习的笔记分享给大家,文中有对应的思维导图图片可供查看,内容与后面正文文本一致。另外,由于SQL语句部分比较基础,基本上会一门数据库就都会,所以此处部分省略掉不做过多记录了。
PostgreSQL命令行安装【静默安装】的全部流程 想要实现通过GUI软件一键安装PostgreSQL的功能,免去手动安装的过程,也可以添加一些对pgsql服务的管理功能。 这就要用到PostgreSQL通过命令行静默安装,放在软件中实现控制...
雨客 微博@JavaChen,这里的所有博客文章来自http://blog.javachen.com/。
相关文章
- docker安装postgresql
- Zabbix监控之安装部署
- 教你Visual Studio Code(VS Code)如何查询PostgreSQL拓展安装教程图解
- 在Ubuntu中安装Postgresql数据库的步骤详解
- PostgreSQL 安装详解新数据库
- PostgreSQL编码协议:改变数据库架构(postgresql协议)
- Mac安装Linux:让操作体验更上一层楼(mac系统安装linux)
- 在Mac上安装Linux虚拟机的指南(mac虚拟机装linux)
- 性能调优优化PostgreSQL内核性能的必要之道(postgresql内核)
- 权限PostgreSQL:配置用户权限(postgresql用户)
- Mac下MySQL安装与下载教程(mac下载mysql)
- Mac 上 Neo4j 的安装与使用(neo4j安装mac)
- 在Mac上安装MySQL数据库(mac安装mysql)
- Mac安装MySQL的步骤教程(mac怎么下载mysql)
- 新手必读:Mac上安装与配置MySQL(mac安装设置mysql)
- Mac安装MySQL小贴士(mac如何安装mysql)
- PostgreSQL 接口:连接数据库的必备工具(postgresql接口)
- PostgreSQL:轻松入门的开源数据库(postgresql介绍)
- PostgreSQL启动指南:快速学会如何启动PostgreSQL数据库。(postgresql启动)
- Mac下安装Oracle数据库遇到的困难(mac安装oracle)
- Mac系统下安装Redis教程(redis安装mac)
- Postgresql参数优化:提升性能的技巧(postgresql参数)
- 轻松搞定:Mac 编译安装 MySQL 教程(mac编译安装mysql)
- PostgreSQL外键:更好的数据库关联性(postgresql外键)
- 如何在PostgreSQL中创建新用户(postgresql创建用户)
- PostgreSQL拼接技巧:实现高效数据整合(postgresql拼接)
- Oracle在Mac上的安装与下载(oracle mac下载)
- 深入理解PostgreSQL背后的原理(postgresql原理)
- PostgreSQL登录:实现无缝连接(postgresql登录)