Navicat Premium16连接VM乌班图Linux虚拟机中的postgresql(12.9)数据库

postgresql版本号:psql (12.9 (Ubuntu 12.9-0ubuntu0.20.04.1))

linux命令

telnet 127.0.0.1 5432 测试 127.0.0.1 的5432端口是否能访问

查看防火墙的状态:sudo ufw status (乌班图)

netstat -nt | grep 23456检查端口23546的使用情况,没有输出。再使用netstat -napt检查所有tcp端口的使用情况

删除安装包

sudo apt-get --purge remove postgresql*

修改环境变量

vi /etc/profile

删除文件夹:

  • rmdir:删除空的文件夹
    • root@ubuntu:/soft#rmdir pgsql_Data/
  • rm:删除一个文件或者文件
    • root@ubuntu:/soft# rm -rf postgresql/

apt操作

通过 apt查询某软件所有的版本号

root@ubuntu:/soft# apt-cache madison postgresql

Ubuntu通过apt-get安装指定版本和查询指定软件有多少个版本 - EasonJim - 博客园 (cnblogs.com)

更新操作:apt-get uodate

查看某软件信息,判断是否安装成功

root@ubuntu:/# dpkg -s postgresql
Package: postgresql
Status: install ok installed
Priority: optional
Section: database
Installed-Size: 66
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Source: postgresql-common (214ubuntu0.1)
Version: 12+214ubuntu0.1
Depends: postgresql-12
Suggests: postgresql-doc
Description: object-relational SQL database (supported version)
 This metapackage always depends on the currently supported PostgreSQL
 database server version.
 .
 PostgreSQL is a fully featured object-relational database management
 system.  It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects.  Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control.  Graphical user interfaces and bindings for many
 programming languages are available as well.
Original-Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>

查看软件安装目录

whereis 软件名

hgfs下没有共享文件夹:vmware-hgfsclient

postgresql连接

修改监听地址 root@ubuntu:/mnt/hgfs# vi /etc/postgresql/12/main/postgresql.conf

将 #listen_addresses= ‘localhost’
取消注释并改为 listen_addresses= ‘*‘

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-U3qrxzuq-1648351141812)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327104544237.png)]

修改可访问用户的IP段

vi /etc/postgresql/12/main/pg_hba.conf

在最后添加:

host all all 0.0.0.0 0.0.0.0 md5

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-YKGgEoWJ-1648351141814)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327105729993.png)]

重启数据库使配置生效:

sudo /etc/init.d/postgresql restart

执行ifconfig查看虚拟机的ip地址

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HItbH7q7-1648351141815)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327110329009.png)]

在主机使用win+R打开命令行窗口输入ping 虚拟机的ip地址查看是否能连上

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4cRgybdH-1648351141815)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327110512301.png)]

在主机打开数据库管理工具,例如navicat

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6qUMGAex-1648351141816)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327110754305.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LEW4x2pN-1648351141816)(C:\Users\天之骄子\AppData\Roaming\Typora\typora-user-images\image-20220327110910882.png)]

连接成功!

参考链接:

(20条消息) PostgreSQL数据库设置登录数据库密码_爱辉弟啦的博客-CSDN博客_postgresql 数据库密码

(20条消息) ubuntu 设置共享文件夹后 /mnt/hgfs 目录为空解决办法_可望*-*的博客-CSDN博客_ubuntu 共享文件夹 空

(20条消息) /mnt/hgfs/下不显示共享文件夹的处理办法_Quincy379的博客-CSDN博客_/mnt/hgfs找不到共享文件夹

(20条消息) vim 撤销上一步操作_Linux笔记(4):vim入门_weixin_39943992的博客-CSDN博客

(20条消息) 在linux下如何显示隐藏文件_huoyin的博客-CSDN博客_linux 隐藏文件

PostgreSQL 语法 | 菜鸟教程 (runoob.com)

(20条消息) Ubuntu PostgreSQL安装和配置 - apt_flowerspring的博客-CSDN博客_apt postgresql

(20条消息) Ubuntu 20.04 | 安装postgresql | apt install_stone_fall的博客-CSDN博客

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值