美文网首页
极简PGSql安装实践

极简PGSql安装实践

作者: 万州客 | 来源:发表于2020-10-15 10:12 被阅读0次

这次集团竞赛,也涉及了PGSql,一起弄弄。

一,下载

https://www.enterprisedb.com/download-postgresql-binaries
现在能找到的二进制安装包,只有下面这个了,将就,差不多。postgresql-10.14-1-linux-x64-binaries.tar.gz
下载之后,解压到一个测试用目录,然后进入这个目录。后面的演示,都是基于这个目录。

二,初始化数据

新建一个数据目录
mkdir data
初始化数据库
bin/initdb -D data
输出如下:

The files belonging to this database system will be owned by user "docker".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... PRC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... 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:

    bin/pg_ctl -D data -l logfile start

三,启动PGSql服务

bin/pg_ctl -D data -l logfile start
输出如下:

waiting for server to start.... done
server started

四,登陆数据库

bin/psql -h localhost -d postgres -U docker -p 5432
由于本地登陆不需要密码,输出如下:

psql.bin (10.14)
Type "help" for help.

postgres=# 

在这个命令行提示符下,就可以大展拳脚啦~

五,常用操作

create database testdb: 新建数据库

\l :查看数据库列表

\du:查看用户

\dt:查看表

\d:查看表结构

\c:切换数据库

\di: 查看索引

\c - user:切换用户

\q: 退出命令行

postgres=# create database testdb
postgres=# \l
                               List of databases
   Name    | Owner  | Encoding |   Collate   |    Ctype    | Access privileges 
-----------+--------+----------+-------------+-------------+-------------------
 postgres  | docker | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | docker | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/docker        +
           |        |          |             |             | docker=CTc/docker
 template1 | docker | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/docker        +
           |        |          |             |             | docker=CTc/docker
 testdb    | docker | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)



postgres=# \dt
Did not find any relations.
postgres=# \d
Did not find any relations.
postgres=# \c testdb
You are now connected to database "testdb" as user "docker".
testdb=# \dt
Did not find any relations.
testdb=# \di
Did not find any relations.

六,启停命令

停止服务
bin/pg_ctl -D data -l logfile stop
重启服务
bin/pg_ctl -D data -l logfile restart

相关文章

  • 极简PGSql安装实践

    这次集团竞赛,也涉及了PGSql,一起弄弄。 一,下载 https://www.enterprisedb.com/...

  • 新年Flag(三)

    1.实践极简生活(物质极简,工作极简,社交极简,学习极简,精神极简,信息极简),实践微习惯。 2.工作 团队管理框...

  • PostgreSQL安装

    Windows 安装 例:安装路径 E:\pgsql\data解压cd .\pgsql\bin 1、初始化init...

  • 极简Kafka安装实践

    伟人们都说过:先让一个Kafka跑起来! 一,下载 http://kafka.apache.org/downloa...

  • PgSQL安装

    下载地址,这边选择下载win64位的 下载后安装报错 There has been an error.an err...

  • pgsql安装

    安装postgresql-server会附带安装上postgres客户端,因此不必重复安装。安装完成,postgr...

  • shp文件导入数据库

    安装Qgis 登陆PGSQL服务器 导入shp文件 关于arcgis连接pgsql数据库 注意: 1.arcgis...

  • “极简”实践

    文/铭悦 身体管理 睡醒的刹那,正好时钟敲打6:00。起床换装成了,习惯。跑下楼,才看到淅淅沥沥下着小雨。晨跑,换...

  • pgsql 安装扩展

    在大多数Linux系统中,如果用户使用的是RPM或DEB打包版本的PostgreSQL,则可选的postgresq...

  • postgresql

    1.安装pgsql yum install https://download.postgresql.org/p...

网友评论

      本文标题:极简PGSql安装实践

      本文链接:https://www.haomeiwen.com/subject/jajnpktx.html