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/
- 浏览: 2487695 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 715MySQL HA Solution 2019(4)MaxSca ... -
MySQL HA Solution 2019(3)MyCat
2019-07-30 11:45 327MySQL HA Solution 2019(3)MyCat ... -
MySQL HA Solution 2019(2)ProxySQL
2019-07-29 09:39 451MySQL HA Solution 2019(2)ProxyS ... -
MySQL HA Solution 2019(1)Master Slave on MySQL 5.7
2019-07-27 22:26 415MySQL HA Solution 2019(1)Master ... -
Zeppelin and Spark Library Dependency
2019-07-09 03:20 425Zeppelin and Spark Library Depe ... -
PostgreSQL 2018(3)Trigger
2018-10-30 00:12 461PostgreSQL 2018(3)Trigger Some ... -
PostgreSQL 2018(2)Dump the Data to CSV
2018-05-05 23:09 538PostgreSQL 2018(2)Dump the Data ... -
PostgreSQL 2018(1)Installation and Introduction
2018-05-04 01:45 589PostgreSQL 2018(1)Installation ... -
SOLR Performance and SolrJ(1)Client Compare Java VS PHP
2017-03-15 06:10 631SOLR Performance and SolrJ(1)Cl ... -
Regis Memory and Cleanup
2017-02-22 06:44 619Regis Memory and Cleanup Get t ... -
Mysql Database Backup and Dump
2016-12-22 06:06 669Mysql Database Backup and Dump ... -
Mysql Database Event and Procedure(3)Stored Procedure
2016-12-07 03:54 640Mysql Database Event and Proced ... -
Mysql Database Event and Procedure(2)Store Procedure
2016-12-07 03:38 547Mysql Database Event and Proced ... -
Mysql Fails on MAC
2015-10-20 03:06 746Mysql Fails on MAC Today, I pl ... -
FIPS and County Code Lookup
2015-10-13 05:19 953FIPS and County Code Lookup Th ... -
MAC OS with Latest Mysql
2015-01-07 12:35 919MAC OS with Latest Mysql C ... -
Cassandra Database(8)Upgrade to 2.1.2 and OpsCenter
2014-12-26 13:12 1208Cassandra Database(8)Upgrade t ... -
Kafka(6)How to Monitor Kafka
2014-08-23 04:19 2219Kafka(6)How to Monitor Kafka1. ... -
neo4j(4)Java Sample/Scala Client and Routing
2014-08-21 23:15 1373neo4j(4)Java Sample/Scala Clie ... -
neo4j(3)Setup neo4j Server and Know Concepts
2014-08-20 01:08 731neo4j(3)Setup neo4j Server and ...
相关推荐
DBeaver是一个SQL客户端和数据库管理工具。对于关系数据库,它使用JDBC API...支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HS DBeaver的社区版是一个自由及开放源代码软件,在Apache License下分发。
数据库设置操作 db-setup-action自动执行本地数据库(基于Docker)的安装和运行。 目前支持: PostgreSQLSQL服务器该安装使用官方Docker映像,请参阅下面每个数据库中的链接。 此操作的主要目的是为测试自动化提供一...
DBeaver (dbeaver-ce-21.2.5-x86_64-setup.exe)适用于Windows 64 位(安装程序)。DBeaver 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby...
其支持:MySQL、Oracle、PostgreSQL、IBM DB2、Microsoft SQL Server、clickhouse、Sybase、ODBC、Java DB (Derby)、Firebird (Interbase)、HSQLDB、SQLite、Mimer、H2、IBM Informix、SAP MAX DB、Cache、Ingres、...
如果您链接 postgres_setup_db_[database] 它将为数据库中的每个普通表设置选择和插入 munin 图,但是 /etc/munin/plugins 目录必须可由您的 munin 进程写入。 需要 /etc/munin/plugin-conf.d/[any filename] 中的...
DBeaver 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby, 以及其他兼容 JDBC 的数...
:clinking_beer_mugs: ... 运行bundle exec rails db:setup 运行bundle exec rails s 该服务器将在http://localhost:3000 数据库期望 对于本地PostgreSQL服务配置,有一些假设。 主机是localhost或127.0.0.1 用户
DBeaver [1] 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby, 以及其他兼容 JDBC 的数据库。DBeaver 提供一个图形界面用来查看数据库结构、...
DBeaver (dbeaver-ce-21.3.2-x86_64-setup.exe)适用于Windows 64 位(安装程序)。DBeaver 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby...
DBeaver 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby, 以及其他兼容 JDBC 的数据库。DBeaver 提供一个图形界面用来查看数据库结构、执行...
DBeaver 通过 JDBC 连接到数据库,可以支持几乎所有的数据库产品,包括:MySQL、PostgreSQL、MariaDB、SQLite、Oracle、Db2、SQL Server、Sybase、MS Access、Teradata、Firebird、Derby 等等。商业版本更是可以支持...
NBA Shots DB Rails应用程序用于填充PostgreSQL数据库,其中包含自1996年以来NBA的所有尝试射门。 博客文章,对数据进行...bundle exec rake db:setup 用法 导入所有可用数据(将需要几个小时): bundle exec rake
在bat_db_1和bat_server_1容器均已构建并运行之后,打开另一个终端并使用以下命令在服务器容器中运行测试: docker exec bat_server_1 sh -c " ./run-tests.sh " 享受。 开发说明 接下来,您将获得有关开发工具...
dbeaver支持很多的数据库,比如常见的MySQL、Oracle、PostgreSQL、IBM DB2等等,
DBeaver 通过 JDBC 连接到数据库,可以支持几乎所有的数据库产品,包括:MySQL、PostgreSQL、MariaDB、SQLite、Oracle、Db2、SQL Server、Sybase、MS Access、Teradata、Firebird、Derby 等等。商业版本更是可以支持...
DBeaver 是一个通用的数据库管理工具和 SQL 客户端,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HS
dbeaver通用数据库工具,支持 MySQL, PostgreSQL, Oracle, DB2, MSSQL, Sybase, Mimer, HSQLDB, Derby
适用于开发人员,SQL程序员,数据库管理员和分析人员的免费多平台数据库工具。...使用插件架构,并为以下数据库提供附加功能:MySQL / MariaDB,PostgreSQL,Greenplum,Oracle,DB2 LUW,Exasol等等。
DBeaver 通过 JDBC 连接到数据库,可以支持几乎所有的数据库产品,包括:MySQL、PostgreSQL、MariaDB、SQLite、Oracle、Db2、SQL Server、Sybase、MS Access、Teradata、Firebird、Derby 等等。商业版本更是可以支持...
python3 setup.py install 要验证安装,请尝试: import pgbase 用法示例 from pgbase . database . db import DB # - создаем объект класса DB db = DB ( user = '<username>' ) # - вып...