PostgreSQL Linux
Installation and use, postgresql update simple manual
1. configuration method:
1
First download any version of postgresql for Linux x86_64
Wget http://downloads.enterprisedb.com/postgresql/postgresql-8.4.1-1-linux-x64.bin
2 postgresql update, text mode installation
Root@imdba.cn ~ #./Postgresql-8.4.1-1-linux-x64.bin-mode text,install postgresql
--------------------------
Welcome to the PostgreSQL setup wizard.
--------------------------
Please specify the directory where PostgreSQL will be installed.
Installation Directory [/opt/PostgreSQL/8.4]:/home/PostgreSQL/8.4,postgresql vs mysql
--------------------------
Please select a directory under which to store your data.
Data directory [/home/PostgreSQL/8.4/data]:
On update cascade postgresql
--------------------------
Postgresql update from select
Postgresql update join
Please
Provide a password for the database superuser (Postgres). A locked Unix,postgresql download
User Account (Postgres) will be created if not present,install postgresql ubuntu.
Password:[
Enter Password]
Retype password:[
Repeated input]
python postgresql update
--------------------------
Please select the port number the server shoshould listen on.
Port [5432]:[
Default port, press enter]
update postgresql
[616] yi_us
[617] yi_us.utf8
[1, 618] zh_cn
[1, 619] zh_cn.utf8
[1, 620] zh_hk
[2, 621] zh_hk.utf8
[622] zh_sg
[623] zh_sg.utf8
[1, 624] zh_tw
[1, 625] zh_tw.euctw
[2, 626] zh_tw.utf8
[627] zu_za
[1, 628] zu_za.iso88591
[629] zu_za.utf8
Please choose an option [1]: 619[
Default character set]
Install PL/pgsql in template1 database? [Y/n]: N [whether to install the template library]
--------------------------
Setup is now ready to begin installing PostgreSQL on your computer.
Do you want to continue? [Y/n]: Y[
Whether to continue installation]
--------------------------
Please wait while Setup instils PostgreSQL on your computer.
Installing
0% ______________ 50% ______________ 100%
########################################
--------------------------
Setup has finished installing PostgreSQL on your computer.
Launch stack builder at exit?
Stack
Builder may be used to download and install additional tools, drivers
And applications to complement your PostgreSQL installation. [Y/n]: Y
3
, The following is the configuration of the user, environment variables, will be successful after a mess
Root@imdba.cn ~ # Cp. bash_profile. bashrc/home/PostgreSQL/8.4/
CP: overwrite '/home/PostgreSQL/8.4/. bash_profile '? Y
CP: overwrite '/home/PostgreSQL/8.4/. bashrc '? Y
Root@imdba.cn ~ # Chown-r Postgres. Postgres/home/PostgreSQL /*
Root@imdba.cn ~ # Ls-LTR/home/PostgreSQL/8.4/. Bash *
-RW-r-1 Postgres 174 Nov 10/home/PostgreSQL/8.4/. bash_profile
-RW-r-1 Postgres 176 Nov 10/home/PostgreSQL/8.4/. bashrc
Root@imdba.cn ~ # Su-Postgres
4,
The database Initialization is complete, similar to the installdb of MySQL.
[Root@imdba.cn data] $ initdb-D/home/PostgreSQL/8.4/data/
The files belonging to this database system will be owned by user "stored s ".
This user must also own the server process.
The database cluster will be initialized with locale en_us.
The default database encoding has accordingly been set to latin1.
The default text search configuration will be set to "English ".
Fixing permissions on existing Directory/home/PostgreSQL/8.4/data... OK
Creating subdirectories... OK
Selecting default max_connections... 100
Selecting default shared_buffers... 32 MB
Creating configuration files... OK
Creating template1 database in/home/PostgreSQL/8.4/data/base/1... O
Initializing pg_authid... OK
Initializing dependencies... OK
Creating System views... OK
Loading System Objects 'descriptions... OK
Creating conversions... OK
Creating dictionaries... OK
Setting privileges on built-in objects... OK
Creating information schema... OK
Vacuuming database template1... OK
Copying template1 to template0... OK
Copying template1 to S... OK
Warning: Enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the-A option
Next time you run initdb.
Success. You can now start the database server using:
Postgres-D/home/PostgreSQL/8.4/Data
Or
Pg_ctl-D/home/PostgreSQL/8.4/data-l logfile start
[Root@imdba.cn data] $
5,
Start the PostgreSQL server Background Service
[Root@imdba.cn data] $ pg_ctl-D/home/PostgreSQL/8.4/data-l logfile start
Server starting
[Root@imdba.cn data] $
Ii. Usage
[Root@imdba.cn data] $ Psql
Psql (8.4.1)
Type "help" for help.
Postgres = #
[Root@imdba.cn bin] $./createdb imdba
[Root@imdba.cn bin] $ Psql imdba
Psql (8.4.1)
Type "help" for help.
Imdba = #/L
List of databases
Name | Owner | encoding | collation | ctype | access privileges
---- + --- + --------
Imdba | S | Latin1 | en_us |
Postgres | Latin1 | en_us |
Template0 | Postgres | Latin1 | en_us | = C/Postgres: Postgres = CTC/Postgres
Template1 | S | Latin1 | en_us | = C/Postgres: Postgres = CTC/Postgres
(4 rows)
Imdba = #
Imdba = #/C Postgres
Psql (8.4.1)
You are now connected to Database "Postgres ".
Postgres = #/C imdba
Psql (8.4.1)
You are now connected to Database "imdba ".
Imdba = # create table imdba (ID int4, name char (16 ));
Create Table
Imdba = # Drop table imdba;
Drop table
Imdba = # create table t_imdba (ID int4, name char (16 ));
Create Table
Imdba = #/d t_imdba
Table "public. t_imdba"
Column | type | Modifiers
--- + ----- + ----
Id | integer |
Name | character (16) |
Imdba = # select * From t_imdba;
Id | Name
-- + ------
1 | imdba
2 | imdba
3 | imdba
(3 rows)
Imdba = # create index idx_t_imdba on t_imdba (ID );
Create Index
Imdba = #/di
List of relations
Schema | Name | type | Owner | table
--- + ----- + --- + ---- + ---
Public | idx_t_imdba | index | S | t_imdba
(1 row)
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # insert into t_imdba values (2, 'imdba ');
Insert 0 1
Imdba = # select * From t_imdba;
Id | Name
-- + ------
1 | imdba
2 | imdba
3 | imdba
2 | imdba
2 | imdba
2 | imdba
2 | imdba
2 | imdba
2 | imdba
(9 rows)
Imdba = #/Q
1
, Back up the database
[@ Tc_10.11.54.21_cnc bin] $ pg_dump
Pg_dump pg_dumpall
[Root@imdba.cn bin] $ pg_dump imdba> imdba. pgsql
[Root@imdba.cn bin] $ more imdba. pgsql
-
-PostgreSQL database dump
-
Set statement_timeout = 0;
Set client_encoding = 'latin1 ′;
Set standard_conforming_strings = off;
Set check_function_bodies = false;
Set client_min_messages = warning;
Set escape_string_warning = off;
Set search_path = public, pg_catalog;
Set default_tablespace = ";
Set default_with_oids = false;
-
-Name: t_imdba; Type: Table; Schema: public; Owner: S; tablespace:
-
Create Table t_imdba (
Id integer,
Name character (16)
);
Alter table public. t_imdba owner to ipvs;
-
-Data for name: t_imdba; Type: Table data; Schema: public; Owner: S
-
Copy t_imdba (ID, name) from stdin;
1 imdba
2 imdba
3 imdba
2 imdba
2 imdba
2 imdba
2 imdba
2 imdba
2 imdba
/.
-
-Name: idx_t_imdba; Type: Index; Schema: public; Owner: S; tablespace:
-
Create index idx_t_imdba on t_imdba using btree (ID );
-
-Name: public; Type: ACL; Schema:-; Owner: S
-
Revoke all on schema public from public;
Revoke all on schema public from ipvs;
Grant all on schema public to ipvs;
Grant all on schema public to public;
-
-PostgreSQL database dump complete
-
2
, Recover the database
[Root@imdba.cn bin] $ dropdb imdba
[Root@imdba.cn bin] $ Psql imdba <imdba. pgsql
[Root@imdba.cn bin] $./createdb imdba
[Root@imdba.cn bin] $ Psql imdba <imdba. pgsql
Set
Set
Set
Set
Set
Set
Set
Set
Set
Create Table
ALTER TABLE
Create Index
Revoke
Revoke
Grant
Grant
[All of the above documents are in bytes, with fewer characters and may contain typos! Gaga!
Written on, $ time