PostgreSQL ne mai zaman kanta tsarin gudanarwa na tsarin dandamali, har da Windows da Linux. Wannan kayan aiki yana goyan bayan yawan adadin bayanai, yana da harshe mai haɗin ciki da kuma tallafawa aikin ta amfani da harsunan shirye-shirye na gargajiya. A cikin Ubuntu, an shigar da PostgreSQL ta hanyar "Ƙaddara" ta yin amfani da ɗakin ajiya na ma'aikata ko masu amfani, kuma bayan wannan aikin shiri, gwadawa da kuma samar da Tables ana aiwatar da su.
Shigar PostgreSQL a Ubuntu
Ana amfani da bayanan bayanai a wurare daban-daban, amma tsarin gudanarwa mai dadi yana ba su dashi mai mahimmanci. Yawancin masu amfani da su a PostgreSQL, shigar da shi a OS kuma fara aiki tare da tebur. Bayan haka, muna so muyi bayanin kowane tsarin shigarwa, mataki na farko da kuma saitin kayan aikin da aka ambata.
Mataki na 1: Shigar da PostgreSQL
Tabbas, ya kamata ka fara da ƙara dukkan fayiloli da ɗakunan karatu zuwa Ubuntu don tabbatar da aikin PostgreSQL na al'ada. Anyi wannan ta yin amfani da na'ura mai kwakwalwa da kuma mai amfani ko wuraren ajiyar ma'aikata.
- Gudun "Ƙaddara" a kowane hanya mai dacewa, misali, ta hanyar menu ko ta danna maɓallin haɗin Ctrl + Alt T.
- Na farko, mun lura da wuraren ajiyar masu amfani, saboda yawancin da aka saba sauke su a can. Saka cikin umurnin filin
sudo sh -c 'echo' bb //apt.postgresql.org/pub/repos/apt/ 'lsb_release -cs'-pgdg main ">> /etc/apt/sources.list.d/pgdg.list'
sa'an nan kuma danna kan Shigar. - Shigar da kalmar shiga don asusunku.
- Bayan wannan amfani
wget -q http://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
don ƙara kunshe. - Ya rage kawai don sabunta tsarin dakunan karatu tare da umarnin da ya dace.
sudo apt-samun sabuntawa
. - Idan kuna sha'awar samun sabon sakon layi na PostgreSQL daga asusun ajiyar ma'aikata, kuna buƙatar rubutawa a cikin na'ura
sudo apt-samun shigar postgresql postgresql-bayar
kuma tabbatar da ƙara fayiloli.
Bayan kammala aikin shigarwa mai kyau, za ka iya ci gaba da ƙaddamar da asusun ajiya, duba aiki na tsarin da daidaitattun farko.
Mataki na 2: Fara PostgreSQL na farko
Gudanar da shigarwar DBMS yana faruwa ta hanyar "Ƙaddara" ta amfani da umarnin da ya dace. Kira ga mai amfani mai amfani kamar wannan:
- Shigar da umurnin
sudo su - postgres
kuma danna kan Shigar. Wannan aikin zai ba ka izinin gudanarwa a madadin asusun da aka samo ta tsoho, wanda ke aiki a matsayin babban abu. - Shigar da na'ura mai sarrafawa a karkashin jagorancin bayanin martabar da ake amfani da ita ta hanyar
psql
. Yin aiki tare da yanayin zai taimaka maka kunnawataimako
- zai nuna duk dokokin da aka samu da kuma muhawara. - Ana duba bayanan game da halin yanzu PostgreSQL ana yin ta
conninfo
. - Fita waje zai taimaka wa tawagar
q
.
Yanzu ku san yadda za a shiga cikin asusun kuma ku tafi kundin sarrafawa, don haka lokaci ya yi don matsawa don ƙirƙirar sabon mai amfani da database.
Mataki na 3: Ƙirƙiri Mai amfani da Database
Ba koyaushe yana dacewa da aiki tare da asusun da ke faruwa ba, kuma ba koyaushe ake bukata ba. Abin da ya sa muke ba da shawarar yin la'akari da hanyar da za a samar da sabon labaran da kuma haɗa shi da wani bayanan raba.
- Kasancewa a cikin na'ura mai kwakwalwa a karkashin jagorancin martaba matsayi (tawagar
sudo su - postgres
) rubutaƙirƙirar - muni
sa'an nan kuma ba shi da suna mai dacewa ta hanyar rubutawa a cikin kirtani mai dacewa. - Na gaba, yanke shawara ko kana so ka ba da damar yin amfani da masu amfani da damar yin amfani da duk albarkatu. Zaɓi zaɓi kawai sannan ka ci gaba.
- Ana amfani da bayanan mai suna da sunan ɗaya kamar yadda aka ambaci asusun, saboda haka ya kamata ka yi amfani da umurnin
createdb lumpics
inda lumpics - sunan mai amfani. - Tsarin yin aiki tare da ƙayyadaddun bayanai yana faruwa ta hanyar
psql -d lumpics
inda lumpics - sunan database.
Mataki na 4: Samar da tebur kuma aiki tare da layuka
Lokaci ya yi don ƙirƙirar tamarku ta farko a cikin jerin bayanai. Wannan hanya kuma ana yin ta ta na'ura mai kwakwalwa, amma ba zai yi wuya a magance manyan dokokin ba, domin duk abin da zaka yi shi ne:
- Bayan motsawa zuwa bayanan, shigar da wadannan shafuka:
Sake TABLE gwajin (
shirin ba da kyauta PRIMARY KEY,
type varchar (50) BA NULL,
launi varchar (25) BA NULL,
rajistan wuri varchar (25) duba (wuri a ('arewa', 'kudu', 'yamma', 'gabas', 'arewa maso gabas', 'kudu maso gabas', 'kudu maso yamma', 'arewa maso yamma')),
shigar_date kwanan wata
);Da farko sunan mai suna kayyade. gwajin (zaka iya zaɓar wani suna). Wadannan suna bayyana kowane shafi. Mun zabi sunayen type varchar kuma launi varchar kawai don misali, za ka iya samun dama ga wani nuni, amma tare da amfani da haruffan Latin. Lambobi a cikin ƙuƙwalwar suna da alhakin girman ɗigin, wanda ke da alaka da bayanan da aka dace a can.
- Bayan shigarwa ya kasance kawai don nuna teburin akan allon tare da
d
. - Kuna ganin aikin mai sauƙi wanda ba ya ƙunshi duk wani bayani duk da haka.
- Sabuwar bayani an kara ta ta hanyar umarni
TASHE A cikin gwaji (nau'in, launi, wuri, install_date) HALITTA ('slide', 'blue', 'kudu', '2018-02-24');
Da farko, an nuna sunan teburin, a cikin yanayinmu shi ne gwajin, to, dukkanin ginshiƙai an jera, kuma ana nuna alamomin da aka nuna, dole ne a rubuce. - Sa'an nan kuma zaka iya ƙara wani layin, alal misali,
TASHE A cikin gwaji (nau'in, launi, wuri, install_date) KASHI ('swing', 'rawaya', 'arewa maso yamma', '2018-02-24');
- Gudun tebur ta hanyar
SANTA * DAGA gwaji;
don kimanta sakamakon. Kamar yadda kake gani, an shirya kome da kyau kuma an shigar da bayanai daidai. - Idan kana buƙatar cire duk wani darajar, yi ta ta hanyar umarni
KASHE DAGA DA KARARWA YAKE irin = 'slide';
ta hanyar ƙayyade filin da aka buƙata a fadi.
Mataki na 5: Shigar phpPgAdmin
Gudanar da bayanai ba a sauƙaƙe ba ne ta hanyar na'ura mai kwakwalwa, don haka yana da kyau in haɓaka shi ta hanyar shigar da phpPgAdmin GUI na musamman.
- Bayani ta hanyar "Ƙaddara" Sauke sababbin sabuntawa don ɗakin karatu via
sudo apt-samun sabuntawa
. - Shigar Ajiyayyen Yanar gizo na Apache
sudo apt-samun shigar apache2
. - Bayan shigarwa, gwada aikinsa kuma daidaita daidaitaka ta yin amfani da shi
sudo apache2ctl configtest
. Idan wani abu ya yi daidai ba, nemi kuskure bisa ga bayanin a kan shafin yanar gizo Apache. - Fara uwar garken ta buga
sudo systemctl fara apache2
. - Yanzu cewa an tabbatar da aikin uwar garken, za ka iya ƙara phpPgAdmin ɗakunan karatu ta hanyar sauke su daga tashar ajiya ta gidan waya
Sudo apt kafa phppgadmin
. - Na gaba, ya kamata ka canza canjin sanyi sau ɗaya. Buɗe ta ta hanyar rubutu na rubutu, ƙayyadewa
gedit /etc/apache2/conf-available/phppgadmin.conf
. Idan rubutun ya karanta kawai, zaka buƙaci umarnin kafin gedit saka masudo
. - Kafin layi "Bukata na gida" saka
#
, don sake saita shi a cikin sharhin, kuma shigar da ƙasaIzinin Daga duk
. Yanzu samun dama ga adireshin zai bude ga dukkan na'urori akan cibiyar sadarwa, kuma ba kawai ga PC ba. - Sake kunna uwar garke yanar gizo
sudo sabis na apache2 sake farawa
kuma jin kyauta don sauka don aiki tare da PostgreSQL.
A cikin wannan labarin, mun duba ba kawai PostgreSQL ba, har ma da shigarwa na uwar garken yanar gizo Apache, wanda aka yi amfani dashi wajen hada LAMP software. Idan kuna sha'awar tabbatar da cikakken aiki na shafukanku da kuma sauran ayyukanku, muna ba ku shawara ku fahimci kanku tare da aiwatar da ƙara wasu abubuwa ta hanyar karatun wani labarinmu a link din.
Duba kuma: Shigar da ɗakin LAMP a Ubuntu