Yuav Ua Li Cas Import Mysql Database

Cov txheej txheem:

Yuav Ua Li Cas Import Mysql Database
Yuav Ua Li Cas Import Mysql Database

Video: Yuav Ua Li Cas Import Mysql Database

Video: Yuav Ua Li Cas Import Mysql Database
Video: How to Import MySQL Database from SQL File using PHP | Import database without phpmyadmin access 2024, Hlis ntuj nqeg
Anonim

MySQL cov ntaub ntawv tswj kev tswj hwm yog ib txoj hauv kev daws teeb meem tshaj plaws rau kev tsim cov ntaub ntawv sau cia thoob ntiaj teb thiab yooj yim rau cov kev pabcuam web. Cov tsav tsheb rau kev ua haujlwm nrog MySQL DBMS tau suav nrog feem ntau ntawm cov kev faib tawm CMS niaj hnub. Rau feem ntau ntawm cov nrov ntawv thiab cov kev tswj cov ntsiab lus, muaj cov ntaub ntawv pov thawj nrog kev pib cov ntaub ntawv. Koj tsuas yog yuav tsum tau import mysql database pib.

Yuav ua li cas import Mysql database
Yuav ua li cas import Mysql database

Tsim nyog

  • - cov ntaub ntawv tso cai rau kev nkag mus rau MySQL server;
  • - console neeg thov mysql.

Cov Lus Qhia

Kauj ruam 1

Npaj MySQL database pob tseg cov ntaub ntawv. Yog tias cov khib nyiab nyob hauv ib qho chaw sau ntawv, tsis muab nws pov tseg. Siv cov peev txheej tsim los yog ntaub ntawv tus thawj tswj fwm.

Kauj ruam 2

Txiav txim siab qhov encoding ntawm cov ntawv sau khib nyiab yog tias nws tsis paub ua ntej. Qhib cov ntaub ntawv hauv ib qho khoos phis lossis cov saib pom tso cai uas hloov kho tau zoo. Xaiv qhov encoding ntawm daim ntawv.

Kauj ruam 3

Txuas rau MySQL server. Khiav mysql neeg pabcuam program los ntawm lub console nrog cov kev cai tswjhwm hostname thiab username. Lub hostname yog teev siv qhov kev xaiv -h kab kab, thiab lub npe neeg siv tau teev tseg siv cov -u xaiv. Koj tseem tuaj yeem qhia tus password ntawm kab ntawv sau nkag mus rau lub server siv - hloov mus, lossis tso tawm qhov no tshem tawm (tom qab ntawd lo lus zais yuav qhia rau thaum kev sib txuas).

mysql -h HostName -u UserName --password = UserPassword

thiab nias tus sau yuam. Ntawm no HostName yog tus hostname (nws tuaj yeem yog qhov cim lossis tus IP chaw nyob), UserName yog DBMS username, thiab UserPassword yog tus password. Yog tias qhov kev sib txuas tau ua tiav, ib cov lus yuav tshwm rau hauv tus npluas, nrog rau cov lus hais kom ua.

Kauj ruam 4

Sau cov ua cim teev los txhawb los ntawm cov neeg rau zaub mov. Nkag mus "QHIA UA PHEM RAU QHOV ROOJ;" hauv lub console. Ntaus Ntaus. Kev txiav txim siab yog tias tus neeg rau zaub mov muaj cov cim teeb tsa uas phim cov cim sau ntawv uas muaj cov ntaub ntawv pov tseg ntawm cov khoom siv txawv teb.

Kauj ruam 5

Muab cov npe teev cov npe hauv ntawv teev tam sim no. Nkag mus "QHIA TXOG COV NTAUB NTAWV;" hauv lub console. Ntaus Ntaus.

Kauj Ruam 6

Tsim cov ntaub ntawv tshiab ntawm MySQL server. Ntaus tus hais kom ua:

TSIM NTAUB NTAWV LEEJ NPLUA `DatabaseName` KOS CAI TOS CharsetNtsib Cov Nyiaj Sau Npe CollateName;

thiab nias Enter. Qhia kom meej lub npe yam xav tau rau DatabaseName parameter. Nws yuav tsum tsis phim rau ib qho ntawm cov npe nyob hauv kab npe tshwm hauv kauj ruam tsib. Rau CharsetName parameter, qhia kom meej lub npe ntawm cov cim teeb tsa uas phim cov cim ntawm cov ntawv sib dhos ntawm cov ntawv pov tseg. Cov npe ntawm cov ua cim tau pom hauv qib plaub. Hloov CollateName nrog tus nqi los ntawm "Default collation" teb ntawm cov xov tooj sib xws hauv tib daim ntawv.

Kauj Ruam 7

Disconnect los ntawm server. Sau q hauv lub console. Ntaus Ntaus.

Kauj ruam 8

Import lub MySQL database. Ntaus cov lus txib zoo li qhov no hauv lub console:

mysql -h HostName -u UserName -D DatabaseName -b B -s -p <filename

nias Sau. Ntaus tus neeg siv lo lus zais. Ntaus Ntaus. Tos kom txog thaum cov ntaub ntawv raug ntsaws. Hloov ntawm DatabaseName, koj yuav tsum hloov lub npe ntawm cov ntaub ntawv uas tsim hauv qib rau. Filename yuav tsum yog tag nrho lossis txoj kev txheeb rau cov ntaub ntawv pob tseg. Cov ntawv yuam kev yuav muab luam rau lub console.

Pom zoo: