PostgreSQL的使用

news/2024/7/9 22:35:31 标签: PostgreSQL, 使用

文章目录

  • 安装与配置
    • 安装
    • 设置防火墙端口
    • 删除密码
    • 设置密码
    • 重启服务
  • 本机使用
    • 登录
    • 查看所有的数据库
    • 创建数据库
    • 删除数据库
    • 使用数据库
    • 查看所有的表
    • 查看表结构
    • 退出

安装与配置

安装

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ sudo apt-get update
heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ sudo apt-get install postgresql

设置防火墙端口

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ sudo iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT

删除密码

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ sudo passwd -d postgres
[sudo] password for heyw: 
passwd: password expiry information changed.

设置密码

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ sudo -u postgres passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

重启服务

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ /etc/init.d/postgresql restart
[ ok ] Restarting postgresql (via systemctl): postgresql.service.

本机使用

登录

heyw@ubuntu:~/code/go/mps/MPS-backend/mps/map-service$ psql -U postgres -h 127.0.0.1
Password for user postgres: 
psql (9.5.19)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=# 

查看所有的数据库

\l (l为L的缩写)

postgres=# \l

创建数据库

postgres=# create database testdb;
CREATE DATABASE

删除数据库

postgres=# drop database testdb;
DROP DATABASE

使用数据库

postgres=# \c testdb;
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
You are now connected to database "testdb" as user "postgres".
testdb=#

查看所有的表

testdb=# \d  

查看表结构

testdb=# \d point_dbs

退出

testdb=# \q

http://www.niftyadmin.cn/n/1636471.html

相关文章

XML 特殊字符处理

转自:http://blog.csdn.net/ldl22847/article/details/7029314 在XML中,有一些符号作为XML 的标记符号,一些特定情况下,属性值必须带有这些特殊符号。 下面主要是讲解一些常用的特殊符号的处理 例一&#…

C++ std::map使用的注意事项

clear可以清除map元素 std::map<int, int> asd; asd[1] 1; asd[2] 4; //此时&#xff0c;map有两个元素 asd.clear(); //此时&#xff0c;map没有任何元素如果读取了map&#xff0c;map会自动生成一个元素 std::map<int, int> asd; //此时&#xff0c;map没有任…

下显示有hdfs却找不到_06166.2.0如何基于FTP的方式访问CDH中HDFS文件系统(续)

作者&#xff1a;余枫1文档编写目的Fayson在前面的文章《0598-6.2.0-如何基于FTP的方式访问CDH中HDFS文件系统》介绍了使用Maven编译hdfs-over-ftp并部署实现通过FTP的方式访问CDH集群。前面文章需要在有网络和Maven的环境下启动服务&#xff0c;为了满足离线环境下使用FTP服务…

喜欢的歌单

文章目录英文歌曲Everytime : Britney SpearsHeartbeats : Amy DeasismontStep By StepNo matter whatHey Jude钢琴曲Childhood Memory英文歌曲 Everytime : Britney Spears Everytime I try to fly 每当我要展翅高飞 I fall without my wings. 却又从云间坠落 I feel so sma…

Linux的基本命令与使用

系统 命令行界面与图形界面切换 在图形界面&#xff0c;按住CTRLALTF1即可切换到命令行界面&#xff0c;密码的输入请使用字母上方的数字输入。 进程操作 查看进程 $ps -aux终止进程 $ kill -9 [进程号]在后台运行程序 $ go run hello &文件 查找文件所在位置 $ l…

Android开发更换字体边距变大

使用说明 在assets创建fonts文件夹&#xff0c;并把字体放在里面 在Activity中更换字体 tv_time(TextView)findViewById(R.id.tv_time); tv_time.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/arial.ttf")); tv_title(TextView) findViewById(R.id.t…

nacosk8s部署_k8s部署nacos - osc_vh89klm7的个人空间 - OSCHINA - 中文开源技术交流社区...

如果是在centos7上直接启动nacos注意修改启动命令 sh startup.sh -m standalone访问路径 http://********:8848/nacos/index.htmlhttps://nacos.io/zh-cn/docs/use-nacos-with-kubernetes.html?tdsourcetags_pctim_aiomsg1. 安装git 并在每台机器上面clone nacos-k8syum ins…

Verilog HDL语法学习心得

1.数字电路基础知识&#xff1a; 布尔代数、门级电路的内部晶体管结构、组合逻辑电路分析与设计、触发器、时序逻辑电路分析与设计 2.数字系统的构成&#xff1a; 传感器 AD 数字处理器 DA 执行部件 3.程序通在硬件上的执行过程&#xff1a; C语言(经过编译)-->该处…