当前位置:网站首页>Ubuntu installation and configuration PostgreSQL (18.04)
Ubuntu installation and configuration PostgreSQL (18.04)
2022-06-26 13:20:00 【Lanterns can only come to the classroom to experience life】
List of articles
Write it at the front
The use of Ubuntu edition :18.04
install
install postgresql
$ sudo apt-get install postgresqlIf it fails, you can update the package
sudo apt-get update
After successful installation , You can see psql Version of
psql --versionIf the installation is successful, output
psql (PostgreSQL) 9.5.25
It can be seen that , there PostgreSQL Version is
9.5After successful installation ,postgresql Automatically created : A database user
postgres( No password by default )、 A data > librarypostgres、 One Linux userpostgresRevise it Linux user
postgresPasswordsudo passwd postgresSwitch to Linux user
postgressu postgresGo to the database command line
psqlOutput after successful execution
psql (9.5.25) Type "help" for help. postgres=#Postgresql The service of is enabled by default , without , You can use the following command :
sudo /etc/init.d/postgresql start # Opening service sudo /etc/init.d/postgresql stop # Close the service sudo /etc/init.d/postgresql restart # Restart the service
see
PostgresqlDatabase directory of ( Where is the data stored )stay psql At the command line of , perform
SHOW data_directory;postgres=# SHOW data_directory; data_directory ------------------------------ /var/lib/postgresql/9.5/main (1 row)/var/lib/postgresql/9.5/mainIs the database directory
To configure ( Optional )
To enable other computers to connect to your PostgreSQL The server
Edit the file
sudo vi /etc/postgresql/9.5/main/postgresql.conf/etc/postgresql/
9.5/main/postgresql.confamong
9.5yes PostgreSQL Version of , It depends on the local versionfind
*#listen_addresses = 'localhost'*, It is amended as followslisten_addresses = '*'If you want to allow IPv4 and IPv6 Connect , Please put ‘localhost’ Replace with ‘::’
listen_addresses = '::'
Modify the database directory
Create a database directory ( Where you need it )
mkdir Directory nameFor example, I created
mkdir /home/test/pg_dbclose Postgresql service
sudo service postgresql stopCopy the data ( from Default database directory Copied to the The database directory you specified )
sudo cp -rf postgresql Default database directory for The database directory you specifiedWhat I do is
sudo cp -rf /var/lib/postgresql/9.5/main /home/test/pg_dbpermissions
sudo chown -R postgres:postgres The database directory you specified sudo chmod 700 The database directory you specifiedWhat I do is
sudo chown -R postgres:postgres /home/test/pg_db sudo chmod 700 /home/test/pg_dbmodify postgresql Of
data_directory( The database directory specified in the configuration file )sudo vi /etc/postgresql/9.5/main/postgresql.conftake
data_directory = '/var/lib/postgresql/9.5/main' # use data in another directoryIt is amended as follows :data_directory = ' The database directory you specified 'What I do is
data_directory = '/home/test/pg_db'start-up Postgresql service
sudo service postgresql start
边栏推荐
- Prototype
- Zoomeeper sets ACL permission control (only specific IP access is allowed to enhance security)
- Echart stack histogram: add white spacing effect setting between color blocks
- Explain C language 11 in detail (C language series)
- J - Wooden Sticks poj 1065
- Use the script to crawl the beautiful sentences of the sentence fan website and store them locally (blessed are those who like to excerpt!)
- [how to connect the network] Chapter 1: the browser generates messages
- 利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
- A few lines of code can realize complex excel import and export. This tool class is really powerful!
- tauri vs electron
猜你喜欢

Processsing mouse interactive learning

Don't mess with full_ Case and parallel_ CASE

May product upgrade observation station

12 SQL optimization schemes summarized by old drivers (very practical)

Mysql database explanation (III)

装饰器(Decorator)

Decorator

原型模式(prototype)

首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证

2. Introduction to parallel interface, protocol and related chips (8080, 8060)
随机推荐
D - 滑雪
Common faults of MySQL database - forgetting database password
[how to connect the network] Chapter 2 (middle): sending a network packet
Es6: iterator
code force Party Lemonade
8. [STM32] timer (TIM) -- interrupt, PWM, input capture experiment (proficient in timer)
Beifu PLC realizes zero point power-off hold of absolute value encoder -- use of bias
Explain C language 10 in detail (C language series)
Here Document免交互及Expect自动化交互
J - Wooden Sticks poj 1065
Processing function translate (mousex, mousey) learning
Electron official docs series: Best Practices
Chapter 01_ Installation and use of MySQL under Linux
[shell] generate strings between specified dates
May product upgrade observation station
8、【STM32】定时器(TIM)——中断、PWM、输入捕获实验(一文精通定时器)
C语言:练习题二
Analysis of state transition diagram of Beifu NC axis
MySQL数据库讲解(六)
Processsing mouse interactive learning