Ungalanda kanjani isofthiwe ye-laptop ASUS K52F

I-PostgreSQL iyisistimu yokuphathwa kwedatha yamahhala esetshenziselwa amapulatifomu ahlukahlukene, kufaka phakathi iWindows neLinux. Ithuluzi lisekela inamba enkulu yezinhlobo zedatha, inelimi lokubhala esakhelwe ngaphakathi futhi isekela umsebenzi usebenzisa izilimi zokuhlela zesigaba. Ubuntu, PostgreSQL ifakiwe nge "Isikhumbuzo" usebenzisa amarekhodi okusemthethweni noma omsebenzisi, futhi ngemva kwalokho umsebenzi wokulungiselela, ukuhlolwa nokudala amatafula kwenziwa.

Faka i-PostgreSQL ku-Ubuntu

I-database isetshenziselwa ezindaweni ezihlukahlukene, kodwa uhlelo lokuphatha olukhululekile lubahlinzeka ngokulawula okukhululekile. Abasebenzisi abaningi bayeke ku-PostgreSQL, bafake ku-OS yabo bese baqala ukusebenza namatafula. Okulandelayo, singathanda ukuhamba ngezinyathelo ukuchaza yonke inqubo yokufaka, ukuqaliswa kokuqala nokusetha ithuluzi elikhulunywe ngalo.

Isinyathelo 1: Faka i-PostgreSQL

Yiqiniso, kufanele uqale ngokungeza wonke amafayela afanelekile nemitapo yezincwadi ku-Ubuntu ukuqinisekisa ukusebenza okujwayelekile kwe-PostgreSQL. Lokhu kwenziwa ngokusebenzisa i-console kanye nomsebenzisi noma i-repositories esemthethweni.

  1. Qalisa "Isikhumbuzo" nganoma iyiphi indlela elula, isibonelo, ngokusebenzisa imenyu noma ngokucindezela inhlanganisela yekhiye I-Ctrl + Alt + T.
  2. Okokuqala, siyabona amarekhodi womsebenzisi, ngoba izinguqulo zakamuva ngokuvamile zilandwa lapho. Faka kumyalo wensimusudo sh -c 'echo "deb //apt.postgresql.org/pub/repos/apt/' lsb_release -cs'-pgdg main" >> /etc/apt/sources.list.d/pgdg.list 'bese uchofoza Ngena.
  3. Faka iphasiwedi ye-akhawunti yakho.
  4. Emva kwalokho ukusetshenziswawget -q //www.postgresql.org/media/keys/ACCC4CF8.asc -O - | engeza ukhiye we-sout-key -ukwengeza amaphakheji.
  5. Ihlala nje kuphela ukuze ubuyekeze amareyibrari wesistimu ngomyalo ojwayelekile.sudo apt-get update.
  6. Uma unesithakazelo sokuthola inguqulo yakamuva yakamuva ye-PostgreSQL kusuka ehhovisi elisemthethweni, udinga ukubhala ku-consolesudo apt-get install postgresql postgresql-contribfuthi uqinisekise ukungeza amafayela.

Lapho uqedile ukufakwa ngokuphumelelayo, ungaqhubeka ukuqala i-akhawunti ejwayelekile, uhlole ukusebenza kwesistimu nokucushwa kokuqala.

Isinyathelo 2: Qala i-PostgreSQL Okokuqala

Ukuphathwa kwe-DBMS efakiwe nakho kwenzeka "Isikhumbuzo" besebenzisa imiyalo efanele. Ukushayela kumsebenzisi ozenzakalelayo kubukeka kanje:

  1. Faka umyalosudo su - postgresbese uchofoza Ngena. Lesi senzo sizokuvumela ukuba uye kubaphathi egameni le-akhawunti eyenziwe ngokuzenzakalelayo, okwamanje isebenza njengeyona eyinhloko.
  2. Ukufaka i-console yokulawula ngaphansi kwesimo sephrofayela esetshenzisiwe kusetshenziswapsql. Ukusebenzelana nemvelo kuzokusiza ukuthi usebenzeusizo- izobonisa yonke imiyalo etholakalayo nezimpikiswano.
  3. Ukubuka ulwazi mayelana neseshini ye-PostgreSQL yamanje kwenziwa nge ukuxhuma.
  4. Phuma imvelo kuzosiza ithimba q.

Manje uyakwazi ukungena ngemvume ku-akhawunti bese uya kukhonsoli yokuphatha, ngakho sekuyisikhathi sokuhambisa ukudala umsebenzisi omusha kanye nedatha yakhe ye-database.

Isinyathelo sesi-3: Yakha Umsebenzisi Ne-Database

Akuyona njalo elula ukusebenza ne-akhawunti ejwayelekile, futhi akudingeki ngaso sonke isikhathi. Yingakho siphakamisela ukucubungula inqubo yokwakha iphrofayli entsha bese sixhumanisa nayo i-database ehlukile.

  1. Ukuba ku-console ngaphansi kwephrofayela yokulawula i-postgres (ithimbasudo su - postgres) bhalai-createuser - engasebenzibese unikeza igama elifanele ngokuthayipha izinhlamvu kulayini olufanele.
  2. Okulandelayo, sinqume ukuthi ufuna ukunikeza amalungelo omsebenzisi wokuqhafaza ukufinyelela zonke izinsiza zesistimu. Vele ukhethe ukhetho olufanele bese uqhubeka.
  3. I-database ingcono okuthiwa igama elifanayo njengoba i-akhawunti ibizwa, ngakho-ke kufanele usebenzise umyalowadala i-lumpicskuphi i-lumpics - igama lomsebenzisi.
  4. Ukuguqulwa ukusebenza ne-database ecacisiwe kwenzekapsql -d lumpicskuphi i-lumpics - igama le-database.

Isinyathelo 4: Ukwakha itafula nokusebenza ngemigqa

Sekuyisikhathi sokudala ithebula lakho lokuqala ku-database ekhethiwe. Le nqubo iphinda yenziwe nge-console, kodwa ngeke kube nzima ukubhekana nemiyalo esemqoka, ngoba konke okumele ukwenze uku:

  1. Ngemva kokuthuthela ku-database, faka ikhodi elandelayo:

    DALA ukuhlolwa kwe-TABLE (
    equip_id serial PRIMARY KEY,
    uhlobo lwama-varchar (50) AKUKHO NULL,
    umbala varchar (25) AKUKHO NULL,
    indawo ye-varchar (25) hlola indawo ('enyakatho', 'eningizimu', 'entshonalanga', 'empumalanga', 'empumalanga', 'empumalanga', 'eningizimu-ntshonalanga', 'enyakatho ntshonalanga')),
    Faka usuku lokufaka_ukufaka
    );

    Okokuqala igama letafula licacisiwe. ukuhlolwa (ungakhetha elinye igama). Okulandelayo kuchaza ikholomu ngayinye. Sakhetha amagama thayipha u-varchar futhi umbala varchar Isibonelo kuphela, ungakwazi ukufinyelela noma yimuphi omunye uphawu, kodwa kuphela ngokusebenzisa izinhlamvu zesiLatini. Izinombolo kubakaki zibophezele ubukhulu bekholomu, okuhlobene ngokuqondile nedatha efanelekile lapho.

  2. Ngemuva kokungena kuyo kuhlala kuphela ukubonisa itafula esibukweni d.
  3. Ubona iphrojekthi elula engenayo imininingwane okwamanje.
  4. Idatha entsha ingezwa ngomyaloFaka ekuhlolweni (uhlobo, umbala, indawo, ukufaka i-akhawunti) VALUES ('slide', 'blue', 'south', '2018-02-24');Okokuqala, igama letafula likhonjisiwe, kithi ukuhlolwa, khona-ke zonke izinsika zihlelwe, futhi amanani kubakaki aboniswa, empeleni ngamacaphuno.
  5. Khona-ke ungakwazi ukwengeza enye umugqa, isibonelo,Faka ngaphakathi kokuhlolwa (uhlobo, umbala, indawo, ukufaka i-akhawunti) VALUES ('swing', 'yellow', 'enyakatho ntshonalanga', '2018-02-24');
  6. Qalisa itafula ngokusebenzisaHLOLA * KUVELA ukuhlolwa;ukuhlola umphumela. Njengoba ubona, konke kuhlelwe ngendlela efanele futhi idatha ifakwe kahle.
  7. Uma udinga ukususa noma yiliphi inani, yenzeni ngomyaloSUSELA ekuhlolweni WHERE uhlobo = 'slide';ngokucacisa insimu edingekayo kumaphuzu.

Isinyathelo 5: Faka phpPgAdmin

Ukuphathwa kwedathabhuku akulula ngaso sonke isikhathi ukwenza nge-console, ngakho-ke kungcono ukuyithuthukisa ngokufaka i-phpPgAdmin GUI ekhethekile.

  1. Okuphambili ngokusebenzisa "Isikhumbuzo" Landa izibuyekezo zakamuva zamathalabhu nge-sudo apt-get update.
  2. Faka i-Apache Web Serversudo apt-get ukufaka apache2.
  3. Ngemuva kokufaka, hlola ukusebenza kwayo nokulungisa kwe-syntax usebenzisai-sudo apache2ctl i-configtest. Uma kukhona okungahambanga kahle, bheka iphutha ngokusho kwencazelo ye-website esemthethweni ye-Apache.
  4. Qala iseva ngokuthayiphasudo systemctl qala i-apache2.
  5. Manje ukuthi ukusebenza kweseva kuqinisekisiwe, ungakwazi ukwengeza amashabhufthi we-phpPgAdmin ngokuwalayisha kusukela ehhovisi elisemthethweni ngeposisudo apt ukufaka phppgadmin.
  6. Okulandelayo, kufanele ushintshe kancane ifayela lokucushwa. Vula nge-notebook ejwayelekile, ecacisagedit /etc/apache2/conf-available/phppgadmin.conf. Uma le dokhumenti ifundwa kuphela, uzodinga umyalo ngaphambili gedit ucacise futhisudo.
  7. Ngaphambi komugqa "Kudinga indawo" beka#, ukuyibuyisela kabusha kumazwana, bese ufaka ngezansiVumela Kuzo zonke. Manje ukufinyelela kukheli kuzovulelwa kuwo wonke amadivayisi kunethiwekhi, hhayi nje nge-PC yendawo.
  8. Qala kabusha iseva yewebhuI-sudo service apache2 iqala kabushafuthi uzizwe ukhululekile ukuhla phansi ukusebenza no-PostgreSQL.

Kulesi sihloko, asiboni kuphela i-PostgreSQL, kodwa futhi ukufakwa kwe-server ye-Apache yewebhu, esetshenziselwa ukuhlanganisa isofthiwe ye-LAMP. Uma unesithakazelo ekuqinisekiseni ukusebenza okugcwele kwamasayithi akho namanye amaphrojekthi, sincoma ukuthi uzijwayeze ngenqubo yokwengeza ezinye izingxenye ngokufunda esinye isici esixhumanisi esilandelayo.

Bheka futhi: Ukufaka i-LAMP suite ku-Ubuntu