PostgreSQL Quick Start introduces how to install and configure the PostgreSQL server in Ubuntu. PostgreSQL is a powerful relational database management system, which is released according to the BSD license [1. PostgreSQL contains many advanced features with good performance and good applicability. PostgreSQL is bound to many programming languages, such as C and C ++.
PostgreSQL Quick Start introduces how to install and configure the PostgreSQL server in Ubuntu. PostgreSQL is a powerful relational database management system, which is released according to the BSD license [1. PostgreSQL contains many advanced features with good performance and good applicability. PostgreSQL is bound to many programming languages, such as C and C ++.
PostgreSQL Quick Start
How to install and configure the PostgreSQL server in Ubuntu
Introduction
PostgreSQL is a powerful relational database management system, which is released in accordance with the BSD license [1. PostgreSQL contains many advanced features with good performance and good applicability.
PostgreSQL is bound to many programming languages, such as C, C ++, Python, Java, PHP, and Ruby. It can operate many things, from simple Web applications to databases with millions of records.
Install
Run the following command to install PostgreSQL:
Sudo apt-get install postgresql
PgAdmin III is a convenient PostgreSQL graphics client. It is suitable for beginners. You can run the following command on the terminal to install pgAdmin III:
Sudo apt-get install pgadmin3
You can also install these packages through the system> System Management> xinlide Package Manager.
Basic server settings
Start
Sudo/etc/init. d/postgresql-8.4 start (postgresql installed in 10.04 is 8.4 by default, if it is 10.10, no version is required)
Sudo/etc/init. d/postgresql-8.4 stop
Set Password
After the installation is complete, we need to change the password of postgres user, otherwise we will not be able to use this database server. Run the psql command as the postgres user. Enter the following in the terminal:
Sudo su ipvs-c psql template1
At this time, a new prompt will appear. Enter the following two commands and replace them with the new password <*** password ***>:
Alter user Login s WITH password' <*** PASSWORD ***> ';
Set the postgres User Password
Sudo passwd ipvs
Then enter your password.
Create a database
Create the first database and name it "mydb". Enter:
Su ipvs
Transferred to postgres user.
An error will be reported when using this method.
Sudo su ipvs-c createdb mydb
After the user logs in to postgres, execute
Createdb mydb
Use the pgAdmin iii gui client
To understand what PostgreSQL can do, you must first learn to use a GUI client and enter:
Pgadmin3
You are now on the main interface of pgAdmin III and click "add database connection" (in the upper left corner ). In the displayed dialog box, enter the address 127.0.0.1, server description, default database "mydb", and your password.
Through this graphic interface, you can create databases, tables, and other objects, query databases, add data, and execute SQL statements. Connect with pgAdmin 3
Manage database servers
Manage Users and permissions
PostgreSQL does not have a simple way to manage users. First, you must edit/etc/postgres/pg_hba.conf and modify its default configuration (the security of the default configuration is very high ), if you want ipvs to manage its users (not related to system users), you need to add the following lines:
8 <-------------------------------------------
# Type database user IP-ADDRESS IP-MASK METHOD
# Rezo local
Host all 10.0.0.0 255.255.255.0 password
8 <-------------------------------------------
It means to use your local network (replace 10.0.0.0/24 with your local network !), Postgres users can connect to the database using the traditional "User Name + password" method.
To create a database and create a user with all permissions for the database, run the following command:
Sudo su ipvs-c createuser-D-A-P myuser
Sudo su ipvs-c createdb-O myuser mydb
The first command is to create A new user. This user has no permission to create A database (-D), and has no permission to create A new user (-). When creating a user, you will be prompted to enter the password. The second command is to create a database 'mydb' with 'myuser' as its owner.