PostgreSQL ndi dongosolo laulere la kusamalira mauthenga osiyanasiyana, ogwiritsidwa ntchito pa mapepala osiyanasiyana, kuphatikizapo Windows ndi Linux. Chidachi chimapereka mitundu yambiri ya deta, ili ndi chinenero chokwanira ndipo imathandizira ntchito pogwiritsa ntchito zinenero zamakono. Ubuntu, PostgreSQL imayikidwa kudzera "Terminal" pogwiritsa ntchito maofesi apamwamba kapena ogwiritsira ntchito, ndipo pambuyo pa ntchito yokonzekera, kuyesa ndikupanga matebulo akuchitika.
Sakani PostgreSQL mu Ubuntu
Maziko akugwiritsidwa ntchito mmadera osiyanasiyana, koma dongosolo la kayendedwe kabwino limapatsa iwo kukhala omasuka bwino. Ogwiritsa ntchito ambiri amaima pa PostgreSQL, kuliika mu OS awo ndi kuyamba kugwira ntchito ndi matebulo. Chotsatira, tikufuna kupita pang'onopang'ono kufotokozera njira yonse yowonjezera, kuyambitsa koyamba ndi kukhazikitsidwa kwa chida chatchulidwacho.
Khwerero 1: Yesani PostgreSQL
Inde, muyenera kuyamba pakuwonjezera mafayilo onse ndi ma libraries ku Ubuntu kuti muzitha kugwira ntchito ya PostgreSQL. Izi zagwiritsidwa ntchito pogwiritsira ntchito console ndi ogwiritsa ntchito kapena zolembera.
- Thamangani "Terminal" mwa njira iliyonse yabwino, mwachitsanzo, kupyolera mu menyu kapena potsindikiza kuphatikiza Ctrl + Alt + T.
- Choyamba, timayang'ana zosungiramo, chifukwa matembenuzidwe atsopano amayamba kuwamasulidwa kumeneko. Lowani mu lamulo la kumunda
sudo sh -c 'echo "deb //apt.postgresql.org/pub/repos/apt/' lsb_release -cs'-pgdg chachikulu" >> /etc/apt/sources.list.d/pgdg.list '
ndiyeno dinani Lowani. - Lowani mawu achinsinsi pa akaunti yanu.
- Mutatha kugwiritsa ntchito
wget -q //www.postgresql.org/media/keys/ACCC4CF8.asc -O - | yowonjezera-key key add -
kuwonjezera phukusi. - Zimangokhala zokonzanso makina osungiramo machitidwe ndi lamulo labwino.
sudo apt-get update
. - Ngati mukufuna kudziwa PostgreSQL yopezeka posachedwa kuchokera ku malo ovomerezeka, muyenera kulemba mu console
sudo apt-get install postgresql postgresql-contrib
ndi kutsimikizira kuwonjezera mafayilo.
Pambuyo pa kukonza bwino, mungathe kupitiriza kufotokozera akaunti yeniyeni, kuyang'ana momwe ntchitoyi ikuyendera komanso kukonzekera koyamba.
Gawo 2: Yambani PostgreSQL Choyamba
Otsogolera a DBMS omwe anaikidwa amapezeka kudzera "Terminal" kugwiritsa ntchito malamulo oyenerera. Kuitana kwa wosuta wosasintha kumawoneka motere:
- Lowani lamulo
sudo su - postgres
ndipo dinani Lowani. Kuchita izi kudzakulolani kuti mupite kwa otsogolera m'malo mwa akaunti yomwe imakhala yosasinthika, yomwe ikugwiritsidwa ntchito panopa. - Kulowa pa console yowonongeka pansi pa chithunzi cha mbiri yomwe ikugwiritsidwa ntchito ndi kudzera
psql
. Kuchita ndi chilengedwe kudzakuthandizani kuyambitsathandizo
- izo ziwonetsa malamulo onse omwe alipo ndi zifukwa. - Kuwona zambiri zokhudza gawo la PostgreSQL likuchitika kudzera
malonda
. - Kutuluka chilengedwe kudzathandiza timu
q
.
Tsopano mukudziwa momwe mungalowere mu akaunti ndikupita ku chithunzithunzi cha kasamalidwe, choncho ndi nthawi yopitilirapo kuti mupange watsopano komanso malo ake osungirako zinthu.
Khwerero 3: Pangani Munthu ndi Zomwe Zili Zosintha
Sikoyenera nthawi zonse kugwira ntchito ndi akaunti yomwe ilipo, ndipo sikuti nthawi zonse ndi kofunika. Ndicho chifukwa chake tikukonzekera kulingalira momwe polojekitiyi idzakhazikitsire ndi kulumikizanitsa ndi deta yosiyana.
- Kukhala mu chitonthozo pansi pa machitidwe olamulira postgres (gulu
sudo su - postgres
) lembanicreateuser --interactive
ndiyeno perekani dzina loyenerera mwa kulemba malemba mu chingwe choyenera. - Chotsatira, sankhani ngati mukufuna kupereka ufulu wogwiritsa ntchito ogwiritsira ntchito zipangizo zonse. Sankhani njira yoyenera ndikupitiriza.
- Mndandanda wa malowa umatchulidwa dzina lomwelo monga akauntiyi, kotero muyenera kugwiritsa ntchito lamulo
adayambitsa zovuta
kumene malonda - dzina la ntchito. - Kutembenuka kukagwira ntchito ndi deta yolongosoka kumapezeka
psql -d lumpics
kumene malonda - dzina la database.
Khwerero 4: Kupanga tebulo ndikugwira ntchito ndi mizere
Ndi nthawi yokonza tebulo lanu loyamba m'masitomu omwe asankhidwa. Ndondomekoyi imathandizidwanso kupyolera mu ndondomekoyi, koma sizikhala zovuta kuthana ndi malamulo akulu, chifukwa zonse muyenera kuchita ndi:
- Mutasunthira ku databata, lowetsani code zotsatirazi:
DZIWANI mayeso (
equip_id yapadera PRIMARY KEY,
mtundu varchar (50) NOT NULL,
mtundu varchar (25) NOT NULL,
Kumwera kumpoto chakumadzulo, 'kum'mwera chakumadzulo', 'kum'mwera chakumadzulo'),
tsambulani_date date
);Choyamba dzina la tebulo lafotokozedwa. mayesero (mukhoza kusankha dzina lina). Zotsatirazi zikufotokoza ndime iliyonse. Tinasankha mayina mtundu wa varchar ndi mtundu wa varchar Mwachitsanzo, mungathe kupeza chiwonetsero china, koma pogwiritsa ntchito zilembo za Chilatini. Mabanki mu makina ali ndi udindo wa kukula kwa chigawocho, chomwe chikugwirizana kwambiri ndi deta yoyenera pamenepo.
- Pambuyo polowamo izo zimangokhala kuti ziwonetse tebulo pulogalamuyo
d
. - Mukuwona polojekiti yophweka yomwe ilibe chidziwitso chilichonse pano.
- Dongosolo latsopano likuwonjezeka kupyolera mu lamulo
YAM'MBUYO YOTSATIRA (mtundu, mtundu, malo, kukhazikitsa_date) VALUES ('slide', 'blue', 'kum'mwera', '2018-02-24');
Choyamba, dzina la tebulo likuwonetsedwa, mwa ife ndilo mayesero, ndiye ndondomeko zonse zatchulidwa, ndipo malingaliro omwe ali m'mabuku amasonyezedwa, makamaka pamagwero. - Ndiye inu mukhoza kuwonjezera mzere wina, mwachitsanzo,
YAM'MBUYO YOTSATIRA (mtundu, mtundu, malo, kukhazikitsa_date) VALUES ('swing', 'yellow', 'kumpoto chakumadzulo', '2018-02-24');
- Kuthamanga tebulo kudutsa
SANKHA * KUYESA kuyesa;
kuyesa zotsatira. Monga mukuonera, zonse zimakonzedwa molondola ndipo deta imalowa bwino. - Ngati mukufuna kuchotsa mtengo uliwonse, chitani kudzera mwa lamulo
PUTANI KUYESA KUYENERA mtundu = 'slide';
powatchula munda wofunikira muzolemba.
Khwerero 5: Sakani phpPgAdmin
Maofesi azinthu zosavuta nthawi zambiri zimakhala zophweka pogwiritsa ntchito console, choncho ndibwino kuti muzisinthe ndi kukhazikitsa wapadera phpPgAdmin GUI.
- Choyambirira kudutsa "Terminal" Sungani zosinthidwa zakusachedwa zamakalata kudzera
sudo apt-get update
. - Ikani Apache Web Server
sudo apt-get kukhazikitsa apache2
. - Pambuyo pokonza, yesani kayendedwe kake ndi kulingalira bwino kwa mawu ake
sudo apache2ctl configtest
. Ngati chinachake chalakwika, yang'anani zolakwika molingana ndi kufotokozera pa webusaiti ya Apache. - Yambani seva polemba
chikondi chimayamba apache2
. - Tsopano kuti opaleshoni ya seva yatsimikiziridwa, mukhoza kuwonjezera makalata a phpPGAdmin powakopera ku malo ovomerezeka apolisi kudzera
sudo apt kukhazikitsa phppgadmin
. - Kenaka, muyenera kusintha pang'ono fayilo yosinthika. Tsegulani kudzera mu bukhu laling'ono, kutsimikizira
gedit /etc/apache2/conf-available/phppgadmin.conf
. Ngati chikalatacho chiwerengedwa -kha, mudzafunika lamuloli gedit onaninsosudo
. - Asanafike "Akufunani m'deralo" ikani
#
, kuti mubwererenso mu ndemanga, ndipo lowetsani pansipaLolani kwa onse
. Tsopano kulumikiza ku adiresi kudzakhala kotseguka kwa zipangizo zonse pa intaneti, osati kwa PC yeniyeni. - Bweretsani seva la intaneti
ntchito yachikondi apache2 ikuyamba
ndipo omasuka kutsika kuti mugwire ntchito ndi PostgreSQL.
M'nkhaniyi, sitinangoyang'ana PostgreSQL, komanso kukhazikitsa webusaiti ya Apache, yomwe imagwiritsidwa ntchito pophatikiza LAMP software. Ngati mukufuna kutsimikiza kuti malo anu ndi mapulojekiti ena akugwira ntchito bwino, tikukulangizani kuti mudzidziwe nokha ndi njira yowonjezera zigawo zina powerenga mndandanda wathu wina.
Onaninso: Kuika LAMP suite mu Ubuntu