PostgreSQL ke tsamaiso ea mahala ea tsamaiso ea basebetsi e sebelisoang bakeng sa lipapali tse sa tšoaneng, ho akarelletsa Windows le Linux. Sesebelisoa se tšehetsa mefuta e mengata ea data, e na le puo e kenyelletsoeng le e tšehetsang mosebetsi ka ho sebelisa lipuo tsa khale tsa lenaneo. In Ubuntu, PostgreSQL e kenngoa kahare "Terminal" ho sebelisa litokomane tsa molao kapa tsa mosebetsing, 'me ka mor'a mosebetsi ona oa ho lokisetsa, ho hlahloba le ho theha litafole ho etsoa.
Kenya PostgreSQL ho Ubuntu
Boitsebiso bo sebelisoa libakeng tse fapa-fapaneng, empa tsamaiso e ntle ea tsamaiso e ba fa taolo e ntle. Basebelisi ba bangata ba emisa PostgreSQL, ba e kenye ka OS ea bona 'me ba qale ho sebetsa le litafole. Ka mor'a moo, re ka rata ho tsamaea ka mohato ho hlalosa ts'ebetso eohle ea ho kenya, tlhahiso ea pele le ho seta sa sesebelisoa se boletsoeng.
Mohato oa 1: Kenya PostgreSQL
Ha e le hantle, o lokela ho qala ka ho eketsa lifaele tsohle tse hlokehang le lilaebraring ho Ubuntu ho netefatsa hore mosebetsi o tloaelehileng oa PostgreSQL. Sena se etsoa ho sebelisa console le mosebedisi kapa litokomane tsa molao.
- Matha "Terminal" ka tsela leha e le efe e loketseng, ka mohlala, ho ea ka menyetla kapa ka ho hatelanya motsoako oa senotlolo Ctrl + Alt + T.
- Ntlha ea pele, re hlokomela mechine e sebelisoang ke mochine, hobane liphetolelo tsa morao-rao hangata li lefshoa moo. Kenya molaong oa tšimo
sudo sh -c 'echo "deb //apt.postgresql.org/pub/repos/apt/' lsb_release -cs'-pgdg ka sehloohong" >> /etc/apt/sources.list.d/pgdg.list '
ebe o tobetsa Kenya. - Kenya password bakeng sa akhaonto ea hau.
- Ka mor'a tšebeliso eo
wget -q //www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key eketsa -
ho eketsa liphutheloana. - E sala feela ho ntlafatsa lilaebraring tsa tsamaiso ka taelo e tloaelehileng.
sudo apt-get update
. - Haeba u thahasella ho fumana tlhahiso ea morao-rao ea PostgreSQL ho tloha lefapheng la molao, u lokela ho ngola ka console
sudo apt-get install postgresql postgresql-contrib
le ho tiisa ho eketsa lifaele.
Ha u qetile ho kenya mekhoa e atlehang, u ka tsoela pele ho qaleng akhaonto e tloaelehileng, ho hlahloba ts'ebetso ea tsamaiso le bocha ba pele.
Mohato oa 2: Qala PostgreSQL Pele
Tsamaiso ea DBMS e kentsoeng e boetse e etsahala ka hara "Terminal" ho sebelisa litaelo tse loketseng. Ho letsetsoa ho sebediswa sa mosebedisi ho shebahale tjena:
- Kenya taelo
sudo ka - postgres
mme u tobetsa Kenya. Ketso ena e tla u lumella hore u ee ho batsamaisi molemong oa akhaonto e entsoeng ka nako e sa lekanyetsoang, eo hona joale e sebeletsang e le eona e ka sehloohong. - Ho kenya console ea taolo tlas'a mokhoa oa boitsebiso o sebelisitsoeng ke ho feta
psql
. Ho sebetsana le tikoloho ho tla u thusa ho sebetsathuso
- e tla bontša litaelo tsohle tse fumanehang le liqabang. - Ho sheba tlhahisoleseding e mabapi le lenaneo la hona joale la PostgreSQL le etsoa ka tsela
conninfo
. - Ho tsoa tikolohong ho tla thusa sehlopha
q
.
Hona joale o tseba ho kena ka akhaonteng mme o ea khomong ea batsamaisi, kahoo ke nako ea ho fetela pele ho bopa mochine e mocha le database ea hae.
Mohato oa 3: Etsa Mosebetsi le Database
Hase kamehla ho loketseng ho sebetsa le akhaonto e tloaelehileng e teng, mme ha ho hlokahale kamehla. Ke ka lebaka lena re hlahisang ho hlahloba mokhoa oa ho theha boitsebiso bo bocha le ho hokahanya le boitsebiso bo fapaneng.
- Ho ba sethaleng tlasa puso ea taolo postgres (sehlopha
sudo ka - postgres
) ngolaho bōpa
ebe o fana ka lebitso le letle ka ho thapa litlhaku ka mohala o nepahetseng. - E latelang, etsa qeto ea hore na u batla ho fa litokelo tsa moqapi oa ho sebelisa mehloli eohle ea tsamaiso. Khetha feela khetho e nepahetseng 'me u tsoele pele.
- Sebaka sa hau sa marang-rang se molemo ho rehoa lebitso le le leng joalokaha akhaonto e ne e bitsoa, kahoo u lokela ho sebelisa taelo
li-lumpics tse entsoeng
moo lumpics - lebitso la mosebedisi. - Phetoho ea ho sebetsa le database e boletsoeng e hlaha ka
psql -d lumpics
moo lumpics - lebitso la boitsebiso.
Mohato oa 4: Ho theha tafole le ho sebetsa ka mela
Ke nako ea ho theha tafole ea hau ea pele ho database e khethiloeng. Ts'ebetso ena e boetse e etsoa ka console, empa e ke ke ea e-ba thata ho sebetsana le litaelo tse kholo, hobane tsohle tseo u lokelang ho li etsa ke ho:
- Ka mor'a hore u fallele database, kenya khoutu e latelang:
BALA TABLE teko (
equip_id serial PRIMARY KEY,
mofuta oa varchar (50) NOT NULL,
mebala varchar (25) HA HO NULL,
sebaka sa varchar (25) hlahloba (sebaka sa 'north', 'south', 'west', 'east', 'northeast', 'ka boroa-bochabela', 'ka boroa bophirimela', 'leboea-bophirima')),
kenya letsatsi le lengolo
);Taba ea pele lebitso la tafole le boletsoeng. teko (o ka khetha lebitso le leng le leng). Lintlha tse latelang li hlalosa moelelo ka mong. Re khethile mabitso mofuta oa varchar le mebala varchar feela bakeng sa mohlala, u ka fumana pontšo leha e le efe, empa feela ka tšebeliso ea litlhaku tsa Selatine. Linomoro tsa li-brackets li ikarabella bakeng sa boholo ba mohala, o amanang ka kotloloho le data e lumellanang le moo.
- Ka mor'a hore e kene ka eona e sala feela ho bontša tafole skrineng ka
d
. - U bona morero o bonolo o se nang tlhahisoleseding leha e le efe e teng.
- Ditaba tse ncha di kenyelletsoa ka taelo
HLOKA TSA tlhahlobo (mofuta, mebala, sebaka, kenya_date) VALUES ('slide', 'blue', 'south', '2018-02-24');
Ntlha ea pele, lebitso la tafole le bonts'itsoe, ho rona le joalo teko, joale meqomo eohle e thathamisitsoe, 'me litekanyetso tsa licheche li bonts'oa, ha e le hantle li qotsitsoeng. - Joale o ka eketsa mola o mong, ka mohlala,
HLOKA TSA teko (mofuta, mobala, sebaka, kenya_date) VALUES ('swing', 'yellow', 'leboea-bophirima', '2018-02-24');
- Tsamaisa tafoleng
Khetho * FROM test;
ho hlahloba sephetho. Joalokaha u ka bona, ntho e 'ngoe le e' ngoe e lokiselitsoe ka nepo 'me data e kenngoa hantle. - Haeba o hloka ho tlosa boleng leha e le bofe, etsa joalo ka taelo
TSOHA Tlhahlobo HA HO mofuta ofe = 'slide';
ka ho bonts'a tšimo e hlokahalang likotsong.
Mohato oa 5: Kenya phpPgAdmin
Ha ho bonolo kamehla ho tsamaisa ditshwantsho tsa marang-rang ka mokhoa o ts'oanelang, kahoo ho molemo ho o ntlafatsa ka ho kenya e khethehileng phpPgAdmin GUI.
- Ntho ea bohlokoa ka ho fetisisa "Terminal" Fumana lisebelisoa tsa morao-rao tsa lilaebrari ka tsela
sudo apt-get update
. - Kenya Apache Web Server
sudo apt-get kenya apache2
. - Kamora ho kenya, leka tlhahlobo ea eona le ho nepahala ha syntaxe u sebelisa
sudo apache2ctl e ikemiselitse
. Haeba ho na le ho hong ho sa tsamaeeng hantle, sheba phoso ho ea ka tlhaloso ho websaeteng ea Apache ea molao. - Qala seva ka ho thapa
sudo systemctl qala apache2
. - Hona joale ts'ebetso ea seva e tiisitsoe, o ka eketsa lilaebrari tsa phpPgAdmin ka ho li boloka ho tsoa lefapheng la liofisi ka molao
sudo apt install phppgadmin
. - E latelang, o lokela ho fetola hanyenyane file ea tlhomamiso. E bule ka buka e tloaelehileng, e hlalosang
gedit /etc/apache2/conf-available/phppgadmin.conf
. Haeba tokomane e baloa feela, o tla hloka taelo pele gedit hlakisa hapesudo
. - Pele ho mohala "Hloka sebaka sa sebakeng seo" beha
#
, ho e khutlisetsa hape, mme u kene ka tlaseLumella ho bohle
. Hona joale ho fihlella atereseng ho tla ba bulehileng bakeng sa lisebelisoa tsohle tse marang-rang, eseng feela bakeng sa PC ea lehae. - Qala hape seva sa websaete
tšebeletso ea sudo apache2 e qala hape
'me u ikutloe u lokolohile ho theoha ho sebetsa le PostgreSQL.
Sehloohong sena, ha rea sheba feela PostgreSQL, empa hape re sheba sethala sa websaete sa Apache, se sebelisetsoang ho kopanya LAMP software. Haeba u thahasella ho etsa bonnete ba lits'ebeletso tsa hau le merero e meng, re u eletsa hore u itlhalose ka mokhoa oa ho eketsa likarolo tse ling ka ho bala sehlooho se seng sa rona ho likahaneng tse latelang.
Bona hape: Ho kenya LAMP suite ho Ubuntu