MySQL ndi imodzi mwazinthu zodziwika bwino komanso zogwiritsidwa ntchito kwambiri pazaumisiri padziko lonse lapansi. Kusinthasintha kwake komanso mphamvu zake zimapangitsa kuti ikhale njira yodalirika yoyendetsera ma data ambiri bwino. Kwa iwo omwe akufuna kukhazikitsa MySQL pamakompyuta awo, nkhaniyi ipereka kalozera waukadaulo sitepe ndi sitepe pa momwe bwino kukhazikitsa. Kuyambira pakutsitsa pulogalamuyo mpaka kusinthidwa koyambirira, chilichonse chofunikira chidzaphimbidwa kuti mutha kusangalala ndi mapindu a kasamalidwe ka databaseyi pantchito yanu.
1. Chiyambi cha kukhazikitsa kwa MySQL
MySQL ndi imodzi mwazinthu zodziwika bwino komanso zogwiritsidwa ntchito kwambiri masiku ano. Amapereka malo otetezeka komanso ofulumira kusungirako, kukonza ndi kuwongolera deta yambiri. Ngati mukufuna kuphunzira kukhazikitsa MySQL pa makina anu, mwafika pamalo oyenera. Pansipa tikupatsani chiwongolero chatsatane-tsatane kuti muyike MySQL m'machitidwe osiyanasiyana ntchito.
Musanayambe kukhazikitsa, ndikofunika kuganizira zofunikira za dongosolo. Onetsetsani kuti makina anu akukwaniritsa zofunikira pakuyika kwa MySQL. Zofunikira zenizeni zikuphatikiza mtundu wa machitidwe opangira, kuchuluka kwa RAM yomwe ilipo ndi disk space.
Mukatsimikizira zofunikira zamakina, mutha kuyamba kukhazikitsa MySQL. M'chigawo chino, tipereka malangizo atsatanetsatane a kukhazikitsa pa machitidwe osiyanasiyana opangira, monga Windows, macOS ndi Linux. Tsatirani njira zomwe zatchulidwa m'gawo lililonse kuti mumalize kukhazikitsa bwino. Kuphatikiza apo, tidzakupatsirani maupangiri ndi njira zina ngati mukukumana ndi zovuta pakukhazikitsa.
2. Zofunikira pakuyika MySQL
Musanayambe kukhazikitsa MySQL, ndikofunikira kuwonetsetsa kuti zofunikira zikukwaniritsidwa. Pansipa pali zinthu zofunika kukhazikitsa MySQL:
- Njira Yogwira Ntchito: MySQL imagwirizana ndi machitidwe osiyanasiyana, kuphatikizapo Windows, Linux ndi MacOS.
- Malo a Diski: Malo okwanira a disk amafunika kuti akhazikitse MySQL ndi zigawo zake zowonjezera. Ndikofunikira kukhala ndi malo osachepera 500 MB.
- Kukumbukira kwa RAM: Ndikofunikira kukhala ndi osachepera 1 GB ya RAM kuti mugwiritse ntchito bwino MySQL.
- Pulojekiti: MySQL imatha kuthamanga pama processor osiyanasiyana, ngakhale tikulimbikitsidwa kukhala ndi purosesa yokhala ndi ma cores angapo kuti igwire bwino ntchito.
Kuphatikiza pazofunikira izi, muyeneranso kuwonetsetsa kuti muli ndi zinthu zotsatirazi zomwe zayikidwa pakompyuta yanu:
- Kugwiritsa ntchito intaneti: Kulumikizana kwa intaneti kumafunikira kuti mutsitse choyikira cha MySQL kapena ma phukusi owonjezera.
- Woyendetsa pawebusayiti: Kuti mupeze zothandizira pa intaneti, monga zolemba kapena mabwalo othandizira, ndibwino kuti mukhale ndi msakatuli woyika.
- Kupeza kwa woyang'anira: Kuti muyike ndikusintha MySQL, kupeza kwa olamulira kumafunika Njira yogwiritsira ntchito.
Pokumbukira zofunikira zonsezi, mudzakhala okonzeka kukhazikitsa MySQL yosalala ndikuonetsetsa kuti makina anu akukwaniritsa zofunikira kuti mugwire bwino ntchito.
3. Koperani mafayilo oyika a MySQL
Kutsitsa mafayilo oyika a MySQL, mutha kutsatira izi:
- Pitani patsamba lovomerezeka la MySQL pa https://www.mysql.com/.
- Mugawo la "Downloads", mupeza mitundu yosiyanasiyana ya MySQL ilipo. Sankhani yoyenera Baibulo malinga ndi zosowa zanu ndi kumadula lolingana Download ulalo.
- Kutsitsa kukamaliza, pezani fayilo yoyika pa kompyuta yanu ndikudina kawiri kuti muyambe kukhazikitsa.
Chonde dziwani kuti pakukhazikitsa kwa MySQL, mutha kuuzidwa zambiri, monga chikwatu chomwe mukupita ndi zoikamo zina. Onetsetsani kuti muwerenge sitepe iliyonse mosamala ndikutsatira malangizo omwe aperekedwa poika.
Kukhazikitsa kukamaliza, mudzakhala ndi mwayi wopeza mafayilo oyika a MySQL, kukulolani kuti muyambe kugwira ntchito ndi database yamphamvuyi pa dongosolo lanu.
4. Kuyika MySQL pa Windows
Itha kukhala ntchito yosavuta potsatira njira zoyenera. Mugawoli, kalozera wa tsatane-tsatane adzaperekedwa kuti amalize kukhazikitsa molondola.
Musanayambe kukhazikitsa, ndikofunikira kuonetsetsa kuti muli ndi zinthu zotsatirazi:
- Dongosolo lothandizira: MySQL imagwirizana ndi mitundu ingapo ya Windows, monga Windows 10, Windows 8 y Windows 7. Onani kugwirizana kwa makina anu ogwiritsira ntchito musanapitilize.
- Fayilo yoyika: Tsitsani fayilo yoyika ya MySQL kuchokera patsamba lovomerezeka. Onetsetsani kuti mwasankha mtundu wolondola kutengera makina anu ogwiritsira ntchito.
- Mwayi wa woyang'anira: Kuti muyike MySQL pa Windows, maudindo otsogolera amafunikira. Onetsetsani kuti muli ndi zilolezo zoyenera musanapitirire.
Pansipa pali njira zoyika MySQL pa Windows:
- Tsitsani ndikuyika:
1. Yendetsani ku tsamba lovomerezeka la MySQL ndikutsitsa fayilo yoyenera yoyika.
2. Thamangani unsembe wapamwamba ndi kutsatira malangizo pa zenera.
3. Pa unsembe, mudzafunsidwa kusankha zoikamo. Ngati ndinu watsopano ku MySQL, tikulimbikitsidwa kuti musankhe njira yosasinthika pakusintha koyambira.
4. Dikirani kuti kuyika kumalize. Akamaliza, uthenga udzawoneka wosonyeza kuti kuyika kwachita bwino.
5. Kukhazikitsa MySQL pa Mac Os
Kuyika MySQL pa Mac OS, pali njira zingapo zomwe zilipo. M'munsimu muli njira zotsatila kuti mumalize kuyika:
- Choyamba, ndikofunikira kuti muwone ngati muli ndi Homebrew pakompyuta yanu. Homebrew ndi woyang'anira phukusi lodziwika bwino pa Mac OS ndipo amapangitsa kukhala kosavuta kukhazikitsa mapulogalamu. Mutha kuyang'ana ngati muli ndi Homebrew yoyika poyendetsa lamulo ili mu terminal:
brew -v. Ngati mulibe Homebrew yoyika, mutha kuyiyika potsatira malangizowo https://brew.sh/. - Mukakhazikitsa Homebrew, mutha kuyigwiritsa ntchito kukhazikitsa MySQL poyendetsa lamulo ili mu terminal:
brew install mysql. Lamuloli litsitsa ndikukhazikitsa mtundu waposachedwa wa MySQL padongosolo lanu. - Mukatha kukhazikitsa, mutha kuyambitsa seva ya MySQL poyendetsa lamulo ili:
mysql.server start. Lamuloli liyambitsa seva ya MySQL kumbuyo ndikukonzekera kugwiritsidwa ntchito.
Kuti muwonetsetse kuti kukhazikitsa kwa MySQL kunali kopambana, mutha kuyendetsa lamulo ili mu terminal: mysql -V. Izi ziwonetsa mtundu wa MySQL woyikidwa padongosolo lanu. Kuphatikiza apo, mutha kuyesa kulumikizana ndikuthamanga mysql -u root, zomwe zimakupatsani mwayi wofikira mzere wamalamulo wa MySQL.
Kumbukirani kuti awa ndi masitepe oyambira kukhazikitsa ndikusintha MySQL pa Mac OS. Malingana ndi zosowa zanu zenizeni, mungafunike kupanga zowonjezera. Mutha kulozera ku zolemba zovomerezeka za MySQL kuti mumve zambiri komanso zitsanzo zatsatanetsatane.
6. Kuyika MySQL pa Linux
MySQL ndi njira yotchuka kwambiri komanso yogwiritsidwa ntchito kwambiri m'malo a Linux. Ndi njira yosavuta ndipo tingathe kuchita izo mu masitepe ochepa chabe. M'munsimu ndi mmene kuchita unsembe.
1. Onani ngati MySQL yayikidwa: Musanayike MySQL, ndibwino kuti muwone ngati idayikidwa kale pakompyuta yanu. Mungathe kuchita izi poyendetsa lamulo ili mu terminal:
"``
mysql - mtundu
"``
Ngati zotuluka ziwoneka ndi mtundu wa MySQL, zikutanthauza kuti zakhazikitsidwa kale. Apo ayi, pitirizani ndi masitepe otsatirawa.
2. Sinthani dongosolo: Musanayike pulogalamu iliyonse pa Linux, ndikofunikira kuonetsetsa kuti dongosololi ndi laposachedwa. Kuti muchite izi, yendetsani malamulo otsatirawa mu terminal:
"``
sudo apt update
sudo apt upgrade
"``
Malamulowa adzasintha nkhokwe zamakina ndikugwiritsa ntchito zosintha zilizonse zomwe zilipo.
3. Ikani MySQL: Dongosolo likangosinthidwa, titha kupitiliza kukhazikitsa MySQL. Kuti muchite izi, yendetsani lamulo ili mu terminal:
"``
sudo apt yikani mysql-seva
"``
Pakukhazikitsa, mudzafunsidwa kuti mulowetse mawu achinsinsi kwa wogwiritsa ntchito mizu ya MySQL. Onetsetsani kuti mumapereka mawu achinsinsi achinsinsi ndikukumbukira, monga momwe mudzafunikira kuti mupeze MySQL.
Ndi masitepe awa, mudzakhala mutayika MySQL pa dongosolo lanu la Linux. Tsopano mutha kuyamba kuyigwiritsa ntchito ndikupezerapo mwayi pazinthu zonse zomwe zimaperekedwa ndi kasamalidwe kamphamvu kameneka.
7. Kukonzekera koyambirira kwa MySQL pambuyo pa kukhazikitsa
Mukangoyika MySQL pamakina anu, ndikofunikira kupanga masinthidwe oyambira kuti muwonetsetse kuti seva yakonzeka kugwiritsidwa ntchito. Kenako, tikuwonetsani masitepe omwe muyenera kutsatira kuti mukonze izi.
1. Sinthani chinsinsi cha ogwiritsa ntchito: Mwachikhazikitso, MySQL imapereka mawu achinsinsi opanda kanthu kwa wogwiritsa ntchito mizu. Izi zitha kupanga dzenje lachitetezo. Kuti musinthe mawu achinsinsi, lowetsani lamulo ili mu terminal: mysqladmin -u root password [nueva-contraseña]. Onetsetsani kuti mwasintha [mawu achinsinsi] ndi mawu achinsinsi omwe mukufuna kukupatsani.
2. Chotsani ogwiritsa ntchito osadziwika: MySQL imapanga mwachisawawa wogwiritsa ntchito wosadziwika yemwe amalola kupeza popanda kupereka mawu achinsinsi. Izi zitha kukhala chiwopsezo chachitetezo. Kuti muchotse anthu osadziwika, yendetsani lamulo ili: mysql -u root -p -e "DELETE FROM mysql.user WHERE User='';". Mudzafunsidwa kuti mulowetse mawu achinsinsi.
8. Kupanga database mu MySQL
Kuti tichite zimenezi, tiyenera kutsatira njira zotsatirazi:
1. Choyamba, tiyenera kutsegula kugwirizana ndi seva ya MySQL. Kuti tichite izi, tigwiritsa ntchito lamulo mysql -u dzina -p pa mzere wolamula. Zidzakhala zofunikira kulowa mawu achinsinsi ogwirizana ndi wogwiritsa ntchito.
2. Tikakhazikitsa kugwirizana, tikhoza Pangani database pogwiritsa ntchito lamulo ili: PANGANI DATABASE_name;. Ndikofunika kukumbukira kuti dzinalo liyenera kutsata malamulo a mayina ndipo lisakhale ndi zilembo zapadera.
9. Kuwongolera kwa ogwiritsa ntchito ndi chilolezo mu MySQL
Ndi ntchito yofunikira kuonetsetsa chitetezo ndi kuwongolera kofikira ku database. MySQL imapereka magwiridwe antchito osiyanasiyana omwe amakulolani kupanga, kuyang'anira ndikusintha ogwiritsa ntchito omwe ali ndi mwayi wosiyanasiyana, womwe ndi wothandiza kwambiri m'malo omwe ogwiritsa ntchito ambiri amapeza database yomweyo.
Kuwongolera ogwiritsa ntchito mu MySQL, malamulo apadera a SQL angagwiritsidwe ntchito. Mwachitsanzo, kuti mupange wosuta watsopano, gwiritsani ntchito lamulo la "CREATE USER", ndikutsatiridwa ndi dzina la wogwiritsa ntchito ndi mawu achinsinsi. Kuphatikiza apo, ndizotheka kupatsa mwayi kwa wogwiritsa ntchito aliyense pogwiritsa ntchito lamulo la "GRANT". Izi zimakupatsani mwayi wofotokozera zomwe angachite pankhokwe, monga SINANI, INSERT, UPDATE kapena DELETE.
Ndikofunika kukumbukira kuti MySQL imakupatsaninso mwayi wowongolera zilolezo pa database ndi patebulo. Mwachitsanzo, lamulo lakuti "PEREKA ZOKHUDZA ZONSE PA database_name.* KUTI 'username'@'localhost'" lingagwiritsidwe ntchito kupereka mwayi wonse kwa wogwiritsa ntchito pa database inayake. Ndikothekanso kuletsa mwayi wopezeka pamatebulo ena pogwiritsa ntchito lamulo la "REVOKE", lomwe limachotsa mwayi womwe wapatsidwa kale.
Mwachidule, ndi ntchito yofunika kuonetsetsa chitetezo ndi kuwongolera mwayi wopezeka mu database. Pogwiritsa ntchito malamulo enieni a SQL, ndizotheka kupanga, kuyang'anira ndi kukonza ogwiritsa ntchito omwe ali ndi maudindo osiyanasiyana, komanso kupereka zilolezo pa database ndi tebulo. Izi zimatsimikizira kuti wogwiritsa ntchito aliyense ali ndi mwayi wodziwa zambiri ndi ntchito zomwe zimagwirizana nawo.
10. Zosintha zamakono mu MySQL
Mu MySQL, pali njira zambiri zosinthira zapamwamba zomwe zimakupatsani mwayi wowongolera ndikuwongolera magwiridwe antchito a database malinga ndi zosowa za polojekiti iliyonse. Mu positi iyi, tiwona zina mwazosankhazi komanso momwe tingazigwiritsire ntchito kuti mafunso anu akhale omveka bwino, komanso kuti mugwiritse ntchito bwino zinthu.
Chimodzi mwazofunikira kwambiri ndikusintha kwa kukonza dongosolo optimizer. MySQL imagwiritsa ntchito optimizer yamkati kuti idziwe dongosolo lothandizira kwambiri pafunso lomwe laperekedwa. Mutha kusintha magawo osiyanasiyana okhudzana ndi ma optimizer kuti musinthe momwe ma index ndi matebulo amasankhidwira ndikutsatiridwa. Mwachitsanzo, mukhoza kusintha mtengo wa optimizer_switch kuyatsa kapena kuletsa kukhathamiritsa kwina kuti muwongolere magwiridwe antchito a mafunso enaake.
Njira ina yofunika ndi kukula kwa buffer ya dongosolo. MySQL imagwiritsa ntchito ma buffers mu-memory kusunga deta ndi zotsatira za mafunso, kuchepetsa kufunikira kwa disk kupeza ndi kupititsa patsogolo ntchito yonse. Mutha kusintha kukula kwa ma buffers pogwiritsa ntchito magawo ngati kutchima_buffer_pool_size kwa InnoDB kapena key_buffer_size kwa MyISAM. Onetsetsani kuti mwagawira kukula koyenera ku ma buffers kutengera zosowa zanu za database ndi zida zomwe zilipo.
11. Kuthetsa mavuto omwe amapezeka nthawi yoyika MySQL
Ngati mukukumana ndi zovuta kukhazikitsa MySQL, musadandaule, nkhaniyi ikutsogolerani njira zothetsera mavuto omwe amapezeka kwambiri. Tsatirani malangizo omwe ali pansipa ndipo mudzatha kumaliza kukhazikitsa popanda zovuta.
1. Yang'anani zofunikira za dongosolo: Onetsetsani kuti dongosolo lanu likukwaniritsa zofunikira zonse zopangira MySQL. Izi zikuphatikizapo Baibulo opaleshoni, mphamvu yosungira yomwe ilipo komanso kukumbukira kwa RAM komwe kumafunikira. Chonde onani zolemba zovomerezeka za MySQL kuti mutsimikizire zambiri zaukadaulo.
2. Yang'anani kukhulupirika kwa fayilo yoyika: Ngati mukukumana ndi zolakwika pakuyika, ndizotheka kuti fayilo yoyikayo yawonongeka kapena yosakwanira. Tsimikizirani kukhulupirika kwa fayilo yomwe mwatsitsa musanapitilize kuyiyika. Mutha kugwiritsa ntchito zida monga lamulo la checksum pamakina a Unix kapena mafayilo owunika kukhulupirika pa Windows.
12. Kusintha kwa mtundu wa MySQL
Ngati mukuyang'ana momwe mungasinthire mtundu wa MySQL, muli pamalo oyenera. Mu positiyi, ndikupatsani mwatsatanetsatane kalozera watsatane-tsatane kuti muthetse vutoli. njira yabwino. Ndi malangizo oyenera ndi zida zofunika, mudzatha kusintha MySQL yanu popanda zopinga zilizonse.
Musanayambe ndondomeko yowonjezera, ndikofunika kuchita a kusunga kuchokera ku database yanu yomwe ilipo. Izi zidzaonetsetsa kuti palibe deta yofunikira yomwe yatayika panthawiyi. Mutha kugwiritsa ntchito zida ngati phpMyAdmin kapena yendetsani malamulo pamzere wolamula kuti mutumize deta yanu ndikuisunga pamalo otetezeka.
Mukasunga database yanu, mutha kupita ku fayilo ya . Pali njira zingapo zochitira izi, koma imodzi mwazosavuta ndikugwiritsa ntchito Phukusi woyang'anira de makina anu ogwiritsira ntchito. Mwachitsanzo, ngati mukugwiritsa ntchito Linux, mutha kugwiritsa ntchito lamulo apt-get kukhazikitsa mtundu waposachedwa wa MySQL. Ngati muli pa Windows, mutha kutsitsa okhazikitsa a MySQL kuchokera patsamba lake lovomerezeka ndikutsatira malangizo oyika.
13. Kuchotsa MySQL
Pansipa pali masitepe oti muchotsere MySQL moyenera padongosolo lanu.
1. Imitsa ntchito ya MySQL: Kuti muchotse MySQL, muyenera kuonetsetsa kuti mwayimitsa ntchitoyo. Mungathe kuchita izi potsegula zenera la lamulo ndikuyendetsa lamulo ili: sudo service mysql stop. Izi zidzaonetsetsa kuti njira zonse zoyendetsera MySQL zayimitsidwa.
2. Chotsani phukusi la MySQL: Ntchito ya MySQL ikangoyimitsidwa, pitilizani kuchotsa phukusi la MySQL kuchokera kudongosolo lanu. Mungathe kuchita izi poyendetsa lamulo ili pawindo la lamulo: sudo apt-get purge mysql-server. Izi zidzachotsa kwathunthu phukusi la MySQL ndi zigawo zake zonse zomwe zikugwirizana ndi dongosolo lanu.
3. Chotsani mafayilo ndi mayendedwe otsala: Ngakhale mutachotsa phukusi la MySQL, pangakhalebe mafayilo okhudzana ndi machitidwe anu. Kuti muwonetsetse kuti mwawachotsa kwathunthu, yendetsani malamulo otsatirawa pawindo la lamulo, limodzi ndi limodzi:
sudo rm -rf /var/lib/mysql- izi zichotsa chikwatu cha data cha MySQL.sudo rm -rf /etc/mysql- izi zichotsa chikwatu cha kasinthidwe ka MySQL.sudo rm -rf /var/log/mysql- izi zichotsa zolemba za MySQL.
14. Malangizo ndi malangizo a kukhazikitsa kolondola kwa MySQL
Kuti mutsimikizire kuyika kolondola kwa MySQL, ndikofunikira kutsatira malangizo ndi malangizo. Nazi njira zabwino zomwe muyenera kukumbukira:
1. Onani zofunikira pa dongosolo: Musanayambe kukhazikitsa, ndikofunikira kuwonetsetsa kuti dongosololi likukwaniritsa zofunikira zochepa zomwe MySQL idakhazikitsa. Izi zikuphatikiza kuyang'ana mtundu wa opareshoni, kupezeka kwa disk space, ndi RAM yomwe ilipo.
2. Gwiritsani ntchito mtundu waposachedwa: Ndibwino kuti nthawi zonse mugwiritse ntchito mtundu waposachedwa kwambiri wa MySQL womwe ulipo. Mitundu yatsopano nthawi zambiri imakhala ndi zosintha zachitetezo, kukonza zolakwika, ndi zatsopano. Mutha kulowa patsamba lovomerezeka la MySQL kuti mutsitse mtundu wosinthidwa kwambiri.
3. Tsatirani malangizo unsembe sitepe ndi sitepe: Ndikofunika kutsatira mosamala malangizo oyika operekedwa ndi MySQL. Malangizowa amaphatikizanso zambiri zamomwe mungakhazikitsire magawo oyika, kukhazikitsa mawu achinsinsi amphamvu, kupanga ogwiritsa ntchito, ndikupereka zilolezo zoyenera. Kuphatikiza apo, zingakhale zothandiza kufunsa maphunziro apa intaneti kapena maupangiri ena omwe amapereka zitsanzo ndi malangizo owonjezera.
Pomaliza, kukhazikitsa MySQL kungakhale njira yaukadaulo koma yotheka kwa iwo omwe akufuna kukhazikitsa ndikuwongolera database yodalirika komanso yothandiza. Potsatira njira zomwe zafotokozedwa pamwambapa, ogwiritsa ntchito akhoza kukhazikitsa MySQL popanda vuto lililonse ndikuyamba kugwiritsa ntchito mphamvu zake zamphamvu. Ndibwino kuti ogwiritsa ntchito apitirize kufufuza ndikuphunzira za luso la MySQL, chifukwa ichi ndi njira yokhayo yopitira kudziko lazotheka poyang'anira ndi kusanthula deta. Ndi chidziwitso cholimba cha MySQL, ogwiritsa ntchito akhoza kukhala okonzeka kukumana ndi zovuta ndi zofunikira zamakono zokhudzana ndi kuyang'anira zambiri zambiri. Kuphatikiza apo, popeza MySQL ndi chida chomwe chimasintha nthawi zonse, kukhala pamwamba pazosintha ndi mitundu yatsopano ndikofunikira kuti muwonetsetse kuti mukugwira ntchito bwino komanso kuti mukhale ndi zochitika zatsopano komanso zosintha. Mwachidule, kukhazikitsa MySQL kungakhale ntchito yaukadaulo, koma ndi chitsogozo choyenera komanso kufunitsitsa kuphunzira, ogwiritsa ntchito adzakhala okonzeka kuti apindule kwambiri ndi database yamphamvuyi.
Ndine Sebastián Vidal, mainjiniya apakompyuta omwe amakonda ukadaulo komanso DIY. Komanso, ine ndine mlengi wa tecnobits.com, komwe ndimagawana nawo maphunziro kuti ukadaulo ukhale wofikirika komanso womveka kwa aliyense.