Umurnin MySQL Yadda ake kunna su daidai?

Idan kun sami wata matsala ta sarrafa bayanai daga wani sabar, kada ku damu, a yau za mu gaya muku duk abin da ya shafi MySQL umarni.

mysql-2-umarni

MySQL umarni

Magana game da ire -iren waɗannan tsarukan da umarni shine kawai yin la’akari da hanyar da za a shigar da bayanai a cikin gidan yanar gizo. Yana da mahimmanci a san yadda ake shigar da umarnin MYSQL ta hanyar matsakaicin fayil, da kuma ta tashar mota.

Tambaya don bayanan yana da mahimmanci don aikin kowane tsarin. Ana yin amfani gabaɗaya ta hanyar shafin PHP, amma kulawa yana dacewa don yin ta ta amfani da shirin PhpMyAdmin; duk da haka, yana faruwa cewa idan akwai matsaloli, mafi dacewa madadin shine shigar da su ta layin umarni.

Hakanan, idan muna kan sabar nesa kuma muna samun shiga ta tashar, dole ne a yi amfani da wannan kayan aikin don dawo da fayilolin da aka ce. A yau za mu ba ku wasu umarni don ku san yadda ake aiwatar da wannan tsari.

Gano fayil

Ana amfani da fayilolin MySQL ta hanyar software na abokin ciniki, wanda tare da shi yana raba iri ɗaya, MySQL. Ana amfani dashi a mafi yawan lokuta don sarrafa bayanai ta hanyar layin umarni; Suna aiki yayin da ake aiwatar da shirye -shiryen fayil daban -daban kuma Dokokin MySQL.

A cikin kowace na’urar da aka shigar da manhajar Windows, ana iya samun wannan fayil ɗin, wurin da yake a adireshin mai zuwa: C: Fayilolin ShirinMySQLMySQL Server 4.1bin.

Hakanan kuna iya samun sa a C: xamppmysql; wannan littafin yana iya zama daban amma da suna kawai.

A kan windows

Misali, wani lokacin kuma dangane da sigar tsarin aikin Windows, yana kan faifai C: ko a kowane wuri a cikin ƙwaƙwalwar kwamfutar, haka nan, ana iya kasancewa a cikin wata hanyar haɗin yanar gizo inda mai shirye -shiryen ya yanke shawarar sakawa. shi. Ya dogara sosai akan wane nau'in shirin da aka yi amfani da shi don shigar da shi.

Amma kar ku damu da binciken, ta amfani da injunan Google ana iya samun su cikin sauƙi, musamman samun madaidaicin fayil, tunda wani lokacin injin injin kwamfuta baya bayar da bayanan da muke buƙata.

mysql-3-umarni

Madaidaicin babban fayil ko wanda kuke so ku sarrafa yana nan kamar yadda Google ya jagoranta. Misali, idan muna kan Windows kuma muna son samun damar madadin MySQL, muna neman kanmu a cikin jagorar ko sanya babban fayil a cikin tsarin PATH.

A Linux

Mun san saukin da Linux ke bayarwa ga duk masu shirye -shirye da masu haɓakawa, kodayake wannan baya nufin yana da sauƙi don samun damar fayilolin MySQL, yana da sauƙi a yi ta layukan umarni; Hakanan ana iya samun sa daga kowane littafin adireshi.

Don haka lokacin da aka sanya injin bayanai, tsarin iri ɗaya yana ba da fayil ɗin "MySQL", ko da wane babban fayil muke ciki, saboda haka sauƙin Linux don aiwatar da wannan aikin.

A kan Mac

Wasu suna tunanin cewa wannan tsarin koyaushe yana da ɗan bambanci idan aka kwatanta da abokan hamayyar sa Windows da Linux, amma yana da ban sha'awa sanin cewa akan Mac ya dogara sosai akan yadda aka sanya fayil ɗin MySQL akan kwamfutar. A wannan yanayin, ba a samun umarnin kai tsaye kamar yadda yake a cikin Linux ko Windows, har ma da tsarin injin ɗin da aka saita.

Don yin wannan, dole ne mu yi bincike akan Google, wanda zai ba mu duk bayanan da muke buƙata don gano shi akan kwamfutar kuma kai tsaye zuwa fayil ɗin "MySQL". Saitin da aka aiwatar a cikin wannan nau'in fayilolin shine amfani a cikin shigar da shirin Mamp; amsar nan take na tsarin zai zama Tambayoyi, wanda zai taimaka mana mu yi amfani da umurnin "mysql" akan Mac kuma shigar da shi tare da sabar Mamp.

mysql-4-umarni

Haɗa zuwa uwar garken MySQL

Bayan gano fayil ɗin MySQL, dole ne ku haɗa zuwa mai sarrafa ta layin umarni. Sannan ci gaba da kiran MySQL, sanya mai gano fayil ɗin tare da sunan ɗaya kuma yana nuna zaɓuɓɓukan haɗin haɗin.

Idan muka sanya «% mysql», za mu sami damar yin amfani da layin umarni kuma daga can za mu iya guje wa asalin hanzari, duk da haka ta hanyar sanya; c: mysqlbin>. Kai tsaye muna watsi da harafin "%".

Alamar tana haɗawa da rumbun adana bayanai gwargwadon sigogi da yanayin da shirin ke da su ta tsohuwa. Sakawa da ɗaure sabar gida tare da sunan mai amfani ko kalmar sirri a cikin kirtani mara amfani; Sannan dole ne ku shigar da wani yanki na bayanai don samun damar haɗi zuwa cibiyar bayanai, alal misali, sanya sigogi masu zuwa: mysql -h server_name -u sunan mai amfani -p.

Yanzu, idan muna son haɗa rumbun adana bayanai zuwa sabar gida ta amfani da sunan mai amfani na tushen, yakamata mu rubuta mai zuwa: mysql -h localhost -u tushen -p, a wannan ma'anar tsarin yana buƙatar kalmar sirri don nau'in mai amfani. Bayan gabatar da shi, muna shigar da layin umarni na MySQL; don haka saurin canzawa zuwa mai zuwa: mysql>

Idan ana nuna kalmar wucewa kai tsaye akan layin umarni, ana iya shigar da shigar nan da nan, amma ba shawara bane saboda dalilan tsaro, a wannan yanayin umurnin zai kasance: mysql -h localhost -u tushen -pmi_key, shigar da -py kada my_key ya bar kowane sarari sai dai idan kuna kan sabar gida.

Waɗannan matakai na shirye -shirye suna da mahimmanci a cikin kowane tsarin aiki, idan kuna son samun ƙarin bayani mai alaƙa da wannan batun, muna gayyatar ku don karanta labarin mai zuwa Yayin cikin shirye -shirye 

Amfani da MySQL console

Bayan mun kasance a cikin na’urar wasan bidiyo, muna da ikonmu a madadin mu duk madadin umarnin MySQL, wanda ke ba mu damar sarrafawa da aiwatar da kowane aiki tare da bayanan bayanai da lambar SQL. Koyaya, yakamata ya zama al'ada don haɗawa zuwa babban cibiyar bayanai da farko, don samun zaɓi na yin aiki cikin aminci.

Sakamakon haka, dole ne a yi amfani da umarnin "amfani" da sunan bayanan da muke son haɗawa, bari mu ga misali: mysql> amfani da rumbun adana bayanai na; sannan muna shigar da bayanan "mybaseddata". Koyaya, dole ne muyi la’akari da duk maganganun da dole ne su kasance cikin layin umurnin MySQL.

Kowane ya ƙare da ";". Don haka idan ba mu sanya waccan kalmar ba, ba za a aiwatar da umurnin ba saboda haka umurnin umurnin zai sake bayyana, wanda ke nuni da cewa dole ne mu ci gaba da shigar da jimloli.

Koyaya, idan kawai muna son aiwatar da bayanin da muka zaɓa a baya ta hanyar sanya «;» Zai isa. A saboda wannan dalili, bai kamata a sake buga cikakken umarnin ba kuma yana nuna ";" kuma buga shiga.

Jerin bayanan bayanai

Don zaɓar takamaiman bayanai dole ne mu yi wani aiki, wanda zai ba mu damar ganin waɗanne ke akwai; don wannan dole ne mu sanya jeri na gaba: mysql> nuna bayanan bayanai; Jerin yana bayyana tare da duk bayanan bayanai da aka samo akan kwamfutarmu. Kuma a ƙarshe ana nuna mai zuwa: mysql> nuna bayanan bayanai ->; 5 layuka a saita (0.02 sec).

Airƙiri tsarin bayanai

Ka tuna cewa muna cikin fayil ɗin Mysql, wanda ke ba mu albarkatun don yin ayyuka daban -daban da suka shafi bayanan bayanai, wani abu da ya zama dole don ƙaura, sarrafawa da loda bayanai zuwa kowane sabar. Idan muna son ƙirƙirar rumbun bayanai, dole ne mu yi waɗannan masu zuwa:

Rubuta "ƙirƙirar bayanai", tare da sunan da muke so mu sanya a cikin sabon ma'ajiyar bayanai, bari mu gani: mysql> ƙirƙiri misalin bayanan bayanai; wannan yana ƙirƙirar fayil.

Wannan zai ƙirƙiri cibiyar bayanai da ake kira "misali", wanda za a yi rijista a cikin MySQL, kuma za mu iya amfani da shi daga baya, don haka idan muna son amfani da shi a nan gaba muna aiwatar da waɗannan ayyuka: mysql> yi amfani da misali.

Gudanar da Database

Wannan rumbun bayanai baya aiki tunda an ƙirƙiri shi, amma idan muna amfani da bayanan da aka riga aka yi amfani da su, dole ne mu rubuta sunan sa. Hakanan, idan muna son amfani ko ganin teburin da suka tsara shi, dole ne mu rubuta "allon tebur", bari mu gani: mysql> nuna tebur.

A cikin wannan ma'anar, bayanan ba ya ƙunshi tebur, bayanai kamar haka nan da nan sun bayyana: "Saitin komai". A akasin wannan, idan akwai tebur da yawa a cikin fayil guda, jerin teburin za su bayyana tare da masu zuwa: layuka 2 a saiti (0.00 sec).

Don samun bayanai masu alaƙa da takamaiman ɗayan kuma kuma mu san abin da ke akwai yankuna, gami da ajin, dole ne mu yi amfani da umarni wanda ke bayyana ƙayyadewa da sunan tebur, kamar masu zuwa: mysql> bayanin mai gudanarwa. Layi 3 a saita (0.11 sec).

Idan kuna son ƙarin sani game da wannan da sauran batutuwa, muna ba da shawarar karanta labarin mai zuwa Dokokin PowerShell inda zaku sami ƙarin bayanai masu alaƙa da wannan batun

Sauran Ayyuka da Hukunci

Duk da yake a cikin kayan aikin MySQL, ana iya yin nuni ta hanyar layin umarni: A wannan ma'anar, ana iya buƙatar kowane nau'in lambar ta amfani da SQL; a can za mu iya yin zaɓuɓɓuka, sabuntawa, ƙirƙirar tebur da sakawa.

Yadda za a yi shi mai sauƙi ne, musamman idan kun san wasu shirye -shirye, tsarin yana da hankali kuma yana da sauƙin cirewa, kawai dole ne mu aiwatar da hukuncin nan da nan bayan sanya semicolon. Bari mu ga misali:

  • mysql> ƙirƙirar gwajin tebur (gwajin id int);
  • Tambaya lafiya, layuka 0 da abin ya shafa (0.08 sec).
  • Hakanan kuna iya amfani da masu zuwa: mysql> saka cikin ƙimar gwaji (id gwajin) (1);
  • Tambaya Ok, shafi 1 ya shafa (0.00 sec).

A ƙarshe, muna fatan mun warware wasu shakku da ke da alaƙa da wannan batun na bayanan MySQL, wanda ke da matukar taimako ga kamfanoni da ƙungiyoyi, idan kuna son samun ƙarin bayani game da shi, kar ku manta da sani da karanta wasu abubuwan da ke cikin mu portal.

 


Abubuwan da ke cikin labarin suna bin ka'idodinmu na ka'idojin edita. Don yin rahoton kuskure danna a nan.

Kasance na farko don yin sharhi

Bar tsokaci

Your email address ba za a buga.

*

*

  1. Hakkin bayanan: Actualidad Blog
  2. Dalilin bayanan: Gudanar da SPAM, gudanar da sharhi.
  3. Halacci: Yarda da yarda
  4. Sadarwar bayanan: Ba za a sanar da wasu bayanan ga wasu kamfanoni ba sai ta hanyar wajibcin doka.
  5. Ajiye bayanai: Bayanin yanar gizo wanda Occentus Networks (EU) suka dauki nauyi
  6. Hakkoki: A kowane lokaci zaka iyakance, dawo da share bayanan ka.