当前位置: 首页 > news >正文

DeepinV20/Ubuntu安装postgresql方法

首先,建议看一下官方的安装文档PostgreSQL: Linux downloads (Ubuntu)

PostgreSQL Apt Repository

简单的说,就是Ubuntu下的Apt仓库,可以用来安装任何支持版本的PgSQL。

If the version included in your version of Ubuntu is not the one you want, you can use the PostgreSQL Apt Repository. This repository will integrate with your normal systems and patch management, and provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.

sort by https://zhengkai.blog.csdn.net/

The PostgreSQL Apt Repository supports the current versions of Ubuntu:

  • kinetic (22.10, non-LTS)
  • jammy (22.04, LTS)
  • focal (20.04, LTS)
  • bionic (18.04, LTS)
  • LinuxDeepin V20 (DeepinV23应该也适用)

Installation steps

# Create the file repository configuration:
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

 

# Update the package lists:

# 配置源后请记得更新一次仓库

sudo apt-get update

# Install the latest version of PostgreSQL.
# 这里建议你安装一下pgsql-15,在2023往后的五年内,可以得到更好的支持。

# If you want a specific version, use 'postgresql-15' or similar instead of 'postgresql':

sudo apt-get -y install postgresql-15

 

Configuration Steps

装完就跑?太天真了,还有一小串step等着你配置呢,这个时候没什么user也没什么db

添加新用户和新数据库新建一个Linux新用户,设置密码

adduser dbuser


切换到postgres用户,将在postgres用户下创建新数据库用户:

sudo su - postgres


登录数据库: 

psql


设置密码:

\password postgres


创建数据库用户dbuser(刚才创建的是Linux系统用户),并设置密码:

CREATE USER dbuser WITH PASSWORD 'password';

创建用户数据库,这里为exampledb,并指定所有者为dbuser:

CREATE DATABASE exampledb OWNER dbuser;

将exampledb数据库的所有权限都赋予dbuser:

GRANT ALL PRIVILEGES ON DATABASE exampledb to dbuser;


退出控制台

\q

 用新用户登陆postgresql

psql -U dbuser -d bics_pro -h 127.0.0.1 -p 5432

如果你登陆过程中遇到Postgresql: password authentication failed for user  "postgres"

sudo -u postgres psql

Inside the psql shell you can give the DB user postgres a password:

ALTER USER postgres PASSWORD 'newPassword';

 

# 创建新表 
CREATE TABLE user_tbl(name VARCHAR(20), create_time TimeStamp);# 插入数据 
INSERT INTO user_tbl(name, create_time) VALUES('moshow', '2023-09-09');# 选择记录 
SELECT * FROM user_tbl;

Connect To Pgsql

Windows下一般推荐Navicat/PgAdmin/DbEaver/DataGrip

Linux下一般我用PgAdmin或者dbeaver(个人更喜欢,万能的连接工具)/DataGrip

这里举个例子,大多数工具初次使用都需要下载驱动,或者使用我的DBeaver-Driver-All ( https://github.com/moshowgame/dbeaver-driver-all )整合所有DBeaver的JDBC驱动包,供DBeaver使用,无需每次都搜索和下载,只需clone本项目即可,一个包包含几乎所有的驱动。

输入完整的登陆信息,数据库(刚才create的BICS_PRO),帐号秘密(dbuser/root123)

点击测试链接,首次连接需要下载驱动,网速允许的情况下,直接下载即可。或者提前准备好jar包。

测试成功。

可以看到我们刚才create的表user_tbl还在

END! 欢迎大家交流DeepinV20/V23使用心得。

http://www.lryc.cn/news/164651.html

相关文章:

  • 汽车ECU软件升级方案介绍
  • 首家!亚信科技AntDB数据库完成中国信通院数据库迁移工具专项测试
  • 为什么好多人想辞职去旅行?
  • vim的使用介绍以及命令大全
  • JavaScript高级技巧:深入探索JavaScript语言的高级特性和用法
  • 虹科方案|HK-Edgility利用边缘计算和VNF降本增效
  • SpringBoot项目--电脑商城【新增收货地址】
  • [HNCTF 2022 Week1]——Web方向 详细Writeup
  • 3dmax vray如何创建真实的灯光?3dmax vray 室内照明教程
  • 如何在本地使用Docker搭建和运行Kubernetes集群
  • 每天几道Java面试题(第二天)
  • Java | 线程的生命周期和安全
  • Bootstrap的一些主要作用
  • 网络编程套接字 | UDP套接字
  • 网络层IP协议
  • C++ Day4
  • 2024字节跳动校招面试真题汇总及其解答(二)
  • SpringBoot集成websocket(4)|(使用okhttp3实现websocket)
  • 【MySQL】JDBC编程
  • 数据结构——二叉树线索化遍历(前中后序遍历)
  • GO语言网络编程(并发编程)Channel
  • c++day3
  • 算法通过村第六关-树青铜笔记|中序后序
  • C++动态内存管理+模板
  • SQL 注入漏洞攻击
  • 一篇五分生信临床模型预测文章代码复现——Figure 10.机制及肿瘤免疫浸润(四)
  • Transformer 模型中常见的特殊符号
  • C# halcon SubImage的使用
  • 每天几道Java面试题:异常机制(第三天)
  • Linux 中的 chattr 命令及示例