PostgreSQL(1)Setup PostgreSQL DB
I know the related things as follow:
cassandra DB, mongo DB, redis DB
Kafka, zookeeper, rabbitMQ, spark.
I begin to learn to know about the PostgreSQL.
1. Installation
Install that on my local MAC OS from here http://www.enterprisedb.com/products-services-training/pgdownload#osx
What I got is here http://get.enterprisedb.com/postgresql/postgresql-9.3.4-1-osx.zip
Double click and install on my machine. Not good for me.
Install from Source
http://ftp.postgresql.org/pub/source/v9.3.4/postgresql-9.3.4.tar.gz
>tar zxvf postgresql-9.3.4.tar.gz
>cd postgresql-9.3.4
>./configure --prefix=/Users/carl/tool/pgsql-9.3.4
>make world
>make install-world
Make the soft link
>sudo ln -s /Users/carl/tool/pgsql-9.3.4 /opt/pgsql-9.3.4
>sudo ln -s /opt/pgsql-9.3.4 /opt/pgsql
>vi ~/.profile
export PATH=/opt/pgsql/bin:$PATH
>. ~/.profile
Verify the Installation
>postgres --version
postgres (PostgreSQL) 9.3.4
2. Prepare the Databases
>mkdir -p /Users/carl/db/postgresql
Initial the DB
>initdb --pgdata=/Users/carl/db/postgresql
Success. You can now start the database server using: postgres -D /Users/carl/db/postgresql or pg_ctl -D /Users/carl/db/postgresql -l logfile start
Check status
>pg_ctl -D /Users/carl/db/postgresql status
Start the server
>pg_ctl -D /Users/carl/db/postgresql start
eg
>pg_ctl -D /database_directory -l /log_file.log start
Error Message:
FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
Solution:
>sudo rm -fr /tmp/.s.PGSQL.5432.lock
Error Message:
LOG: could not bind Unix socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, remove socket file "/tmp/.s.PGSQL.5432" and retry. WARNING: could not create Unix-domain socket in directory "/tmp" FATAL: could not create any Unix-domain sockets
Solution:
>sudo rm -fr /tmp/.s.PGSQL.5432
Solved
LOG: database system was shut down at 2014-03-21 16:59:46 CDT LOG: autovacuum launcher started LOG: database system is ready to accept connections
List the databases we have
>psql -l
3. Create the Right DB with Auth
List all the users on MAC System
>ls /Users
Create a user named postgres
>su postgres
>psql
Error Message:
FATAL: role "postgres" does not exist psql: FATAL: role "postgres" does not exist
Solution:
>createuser postgres
>createdb -Opostgres -Eutf-8 demo
Logon to the DB with the right user
>psql -U postgres demo
or
>psql -U postgres -d demo -h localhost -p 5432
4. Some Basic Commands
List all the Databases
demo=> \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+------------------- demo | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
Connect to other databases
demo=> \c demo You are now connected to database "demo" as user "postgres". demo=> demo=> \c postgres You are now connected to database "postgres" as user "postgres".
SQL Command
create table, insert data and etc
>create table usertable(name VARCHAR(20), signupdate DATE);
>insert into usertable (name, signupdate ) values ('sillycat', '2014-03-24' );
>select * from usertable;
List all the tables We have
demo=> \d List of relations Schema | Name | Type | Owner --------+-----------+-------+---------- public | usertable | table | postgres
List the description of one Table, e.g. usertable
demo=> \d usertable Table "public.usertable" Column | Type | Modifiers ------------+-----------------------+----------- name | character varying(20) | signupdate | date |
List all the Users
demo=> \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- carl | Superuser, Create role, Create DB, Replication | {} postgres | | {}
List the Connection Info
demo=> \conninfo You are connected to database "demo" as user "postgres" on host "localhost" at port "5432".
References:
http://www.postgresql.org/
https://github.com/mauricio/postgresql-async
http://book.51cto.com/art/201201/313178.htm
http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html
http://mac-dev-env.patrickbougie.com/postgresql/
http://ionrails.com/2012/06/03/installing-postgresql-on-a-mac-lion/
- 浏览: 2542923 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
MySQL HA Solution 2019(4)MaxScale
2019-08-03 21:19 788MySQL HA Solution 2019(4)MaxSca ... -
MySQL HA Solution 2019(3)MyCat
2019-07-30 11:45 369MySQL HA Solution 2019(3)MyCat ... -
MySQL HA Solution 2019(2)ProxySQL
2019-07-29 09:39 485MySQL HA Solution 2019(2)ProxyS ... -
MySQL HA Solution 2019(1)Master Slave on MySQL 5.7
2019-07-27 22:26 514MySQL HA Solution 2019(1)Master ... -
Zeppelin and Spark Library Dependency
2019-07-09 03:20 457Zeppelin and Spark Library Depe ... -
PostgreSQL 2018(3)Trigger
2018-10-30 00:12 487PostgreSQL 2018(3)Trigger Some ... -
PostgreSQL 2018(2)Dump the Data to CSV
2018-05-05 23:09 566PostgreSQL 2018(2)Dump the Data ... -
PostgreSQL 2018(1)Installation and Introduction
2018-05-04 01:45 631PostgreSQL 2018(1)Installation ... -
SOLR Performance and SolrJ(1)Client Compare Java VS PHP
2017-03-15 06:10 673SOLR Performance and SolrJ(1)Cl ... -
Regis Memory and Cleanup
2017-02-22 06:44 653Regis Memory and Cleanup Get t ... -
Mysql Database Backup and Dump
2016-12-22 06:06 700Mysql Database Backup and Dump ... -
Mysql Database Event and Procedure(3)Stored Procedure
2016-12-07 03:54 677Mysql Database Event and Proced ... -
Mysql Database Event and Procedure(2)Store Procedure
2016-12-07 03:38 584Mysql Database Event and Proced ... -
Mysql Fails on MAC
2015-10-20 03:06 783Mysql Fails on MAC Today, I pl ... -
FIPS and County Code Lookup
2015-10-13 05:19 985FIPS and County Code Lookup Th ... -
MAC OS with Latest Mysql
2015-01-07 12:35 966MAC OS with Latest Mysql C ... -
Cassandra Database(8)Upgrade to 2.1.2 and OpsCenter
2014-12-26 13:12 1243Cassandra Database(8)Upgrade t ... -
Kafka(6)How to Monitor Kafka
2014-08-23 04:19 2248Kafka(6)How to Monitor Kafka1. ... -
neo4j(4)Java Sample/Scala Client and Routing
2014-08-21 23:15 1397neo4j(4)Java Sample/Scala Clie ... -
neo4j(3)Setup neo4j Server and Know Concepts
2014-08-20 01:08 764neo4j(3)Setup neo4j Server and ...
相关推荐
1. 解压"timescaledb-postgresql-12_1.7.1-windows-amd64.zip"压缩包,找到并运行"setup.exe",按照向导进行安装。 2. 安装完成后,将解压目录下的"timescaledb"文件夹复制到PostgreSQL的"share\extension"目录下。 ...
安装TimescaleDB扩展时,用户需要先安装PostgreSQL 13,然后使用`setup.exe`或手动运行SQL脚本来加载和启用扩展。使用`timescaledb-tune.exe`工具进行参数调优,根据实际需求设置合适的分片策略。一旦安装完成,...
"psqlodbc-setup.exe"文件是PostgreSQL的ODBC驱动程序安装包,它允许你在Windows上通过ODBC(Open Database Connectivity)接口与PostgreSQL数据库进行通信。ODBC是一个标准的应用程序编程接口(API),使得不同的...
初始化数据库并启用自动启动,命令为:/usr/pgsql-9.3/bin/postgresql93-setup initdb、systemctl enable postgresql-9.3 和 systemctl start postgresql-9.3 四、添加新用户和新数据库 1. 新建一个 Linux 新用户...
- `setup.exe`:这是安装程序,用户可以通过执行这个程序来安装TimescaleDB扩展,将其集成到PostgreSQL 12环境中。安装过程中会涉及创建数据库、加载扩展、配置参数等步骤。 4. 时间序列数据处理: - TimescaleDB...
- 打开`setup\build.db.properties`文件,并修改为使用PostgreSQL的相关配置,如: ```properties db=activiti jdbc.driver=org.postgresql.Driver jdbc.url=jdbc:postgresql://localhost:5432/activiti jdbc....
利用rpm包进行简便的pg库部署安装,避免跟进源文件进行编译,需要根据postgresql版本问题存在的依赖查找,以及postgis插件与postgresql版本对应关系问题,减少了各个依赖版本间查找,以及各种依赖不正确,需要根据一...
/usr/pgsql-11/bin/postgresql-11-setup initdb ``` - **启动服务**:通过Systemd服务管理工具启动PostgreSQL服务。 ```shell systemctl enable postgresql-11 systemctl start postgresql-11 ``` **2.5 重置...
- 初始化数据库是安装后的关键步骤,使用`postgresql-setup --initdb`命令来完成,这会创建默认的数据目录,例如 `/var/lib/pgsql/data`。 - 配置启动服务以便在系统启动时自动运行PostgreSQL,通过`systemctl ...
4. **初始化数据库**:运行`postgresql-setup --initdb`来初始化数据库集群。 5. **启动和启用服务**:用`systemctl start postgresql-10`启动服务,然后用`systemctl enable postgresql-10`设置开机启动。 6. **...
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb sudo systemctl start postgresql-12 ``` 配置PostgreSQL允许远程连接(如果需要的话)并在防火墙中打开5432端口: ```bash sudo vi /var/lib/pgsql/12/data/...
DBeaver经官方测试,其支持:MySQL、Oracle、PostgreSQL、IBM DB2、Microsoft SQL Server、clickhouse、Sybase、ODBC、Java DB (Derby)、Firebird (Interbase)、HSQLDB、SQLite、Mimer、H2、IBM Informix、SAP MAX ...
1. **DBeaver 安装**:首先,你需要解压 "dbeaver-ce-21.1.3-x86_64-setup.zip" 文件,然后运行 "dbeaver-ce-21.1.3-x86_64-setup.exe" 执行安装过程。根据向导的提示,选择合适的安装路径和配置选项。 2. **驱动...
压缩包内的文件 "psqlodbc-setup.exe" 是安装程序,用户可以通过运行这个可执行文件来安装PostgreSQL的ODBC驱动。"README.txt" 文件通常包含安装指南、许可协议和其他重要信息,对于正确配置和使用驱动至关重要。...
sudo -u postgres vacuumdb --all --maintenance-db=template1 ``` 至此,PL/Python3扩展已经在你的CentOS7上的PostgreSQL中成功启用,你可以通过创建存储过程来利用Python的强大功能处理数据。例如: ```sql ...
你也需要一个Web服务器如Apache或Nginx,以及一个SQLite、MySQL或PostgreSQL数据库。 2. **创建新项目**:通过Composer在全球范围内安装Laravel。打开终端,输入`composer global require laravel/installer`。然后...
此外,“所有数据库都可以连接”这一描述意味着它还兼容如Oracle、SQL Server、PostgreSQL、SQLite、MongoDB等其他主流数据库系统,极大地提高了开发人员和数据库管理员的工作效率。 Dbeaver的特性之一是它的直观...
DBeaver是一个SQL客户端和数据库管理工具。对于关系数据库,它使用JDBC API...支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HS DBeaver的社区版是一个自由及开放源代码软件,在Apache License下分发。
数据库设置操作 db-setup-action自动执行本地数据库(基于Docker)的安装和运行。 目前支持: PostgreSQLSQL服务器该安装使用官方Docker映像,请参阅下面每个数据库中的链接。 此操作的主要目的是为测试自动化提供一...