Feed on
Subscription

How be installed and check MySQL

A kind of when PHP+MySQL+Linux already became small-sized Web server gradually at present classical combination.A kind of first selection that be built below Windows environment and debugging MySQL database is a lot of website developer.Oneself issue MySQL of begin to learn in Windows98 environment,Come out learning process and experience summary to consult for everybody now.
1, download Mysql-3.23.35-win.zip and solution is pressed;
2, moving Setup.exe; chooses D:\Mysql, "Tyical Install "
3, the Mysql that start,Be like lower part law:

Method one:Use Winmysqladmin
1) , enter D: \mysql\bin catalog,Moving Winmysqladmin.exe,In screen right the meeting inside the task column of next horn has an erubescent plan accord with
Wrong key of 2) , mouse clicks this graph accord with,Choose " Show Me " ,Appear " WinMySQLAdmin " operation interface;The user name that a dialog box can appear to the requirement is inputted and install you among the meeting when moving first and countersign
3) , choice " My.INI Setup "
4) , in " Mysqld File " be chosen choose " Mysqld-opt " (Win9x) or " Mysqld-nt " (WinNT)
5) , choice " Pick-up Or Edit My.ini Values " can be opposite inside right window your My.ini file has an edition
6) , choice " Save Modification " the My.ini file that saves you
7) , when if you want to use Winmysqladmin(quickly,switching on the mobile phone move automatically) ,Choose " Create ShortCut On Start Menu "
8) , test:
Enter DOS interface;
In D:\Mysql moves below Mysql\bin catalog,Enter Mysql to operate an interface interactively
Input Show Databases and carriage return,Screen is shown current already some two databases Mysql and Test

Method two:Do not use Winmysqladmin

1) , below DOS window,Enter D:/mysql/bin list
Below 2) , Win9X) move: Mysqld
Move below NT: Mysqld-nt- - Standalone
3) , after this,Mysql backstage moves
?of Mysql: of 4) , test? ?: / below Mysql/bin catalog)Show when A) , Mysqlshow is normal already some two databases Mysql and TestFive lists in database Mysql show when B) , Mysqlshow -u Root Mysql is normal:


...

Let MySQL and OpenOffice in all dance

? ? a year ago,A when I became Linux user,But old use Windows,Let me feel some Linux tools are used not very habit.Take a database for,Below Windows,The website that develops drive of a few databases can choose to use Access when system of small-sized perhaps management.Access is used easily not only,And very convenient.After turning to Linux,When doing same business, discover MySQL is a right choice,But its do not have graphical interface,Use rising is not very convenient,Then the hope can find settlement program.Pass period of time seek,Found eventually settle way,Use MySQL and OpenOffice band namely.Show according to the data,The method that implementation MySQL and OpenOffice work in coordination has a lot of to plant,Nevertheless mostly too complex,Be hard to come true.Here I introduce two kinds of installation and configuration course.

The operating system that I use ? ? is Red Hat 8.0,The emission that same method uses at other edition is likely have a bit different.In how rigging buy process,Need MySQL and UnixODBC software package (had installed below OpenOffice default circumstance) .These software packages had been taken oneself in the CD of Red Hat 8.0,But in my test,Use installation dish the method cannot succeed it seems that.

? ?Installation deploys a method one



? ? 1. Download software

The software package that ? ? place needs has:


...

How to retrieve data from inside MySQL database watch

1, retrieve information from inside database watch

Actually,We had used SELECT statement in front,It is used retrieve information from inside database watch.Select statement form is commonly:
The watch WHERE that FROM of keyword of SELECT retrieval is retrieved retrieves a condition (optional)
What use previously " * " express to choose all lines.
Continue to use us below going up a watch Mytable that founds in the article.

2, inquire all data:


...

Found database and database watch with MySQL

1, use SHOW statement finds out current on the server presence what database:





mysql%26gt; SHOW DATABASES; 
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
3 rows in set (0.00 sec)
...

MySQL data guides derive tool Mysqlimport brief introduction

? ?1) the grammar introduction of.mysqlimport:

? ? Mysqlimport is located in in Mysql/bin catalog,One be Mysql loads (perhaps say to guide) a of data very effective tool.This is tool of travel of a command.Two parameter and many options can offer an alternative.This tool file of a text (Text File) in the database that guides you are appointed and watch.In saying we want to guide data into the watch Custermers in database Meet_A_Geek from inside file Customers.txt for example:
? ? Mysqlimport Meet_A_Geek Customers.txt
? ? notices:Customers.txt is we should guide here the text file of data,And Meet_A_Geek is the database that we should operate,
The watch name in ? ? database is Customers,The data format of here text file must agree with the format in Customers watch,Otherwise Mysqlimport command will make mistake.The name that expresses among them is to guide the first full stop of the file (. ) in front file string,Another example:
? ? Mysqlimport Meet_A_Geek Cus.to.mers.txt
? ? so we will guide the content in the file into the Cus watch in database Meet_A_Geek.
In the example above ? ? ,Use two parameter only,Did not use more option,The option of Mysqlimport introduces below
? ?
? ?2) the commonly used option of.mysqlimport introduces:

Function of ? ? option
? ? - D Or- - Delete new data guides data data is deleted to express all medium information before data table is medium
? ? - F Or- - no matter whether Force encounters a mistake,Mysqlimport will continue compulsively to insert data
? ? - I Or- - Ignore Mysqlimport is jumped over or those have oversight the travel of identical and only key word,Guide the data into the file will by oversight.
? ? - before data of L Or -lock-tables is inserted, chain watch,Prevented so,When you are updating a database,The inquiry of the user and be affected newlier.
? ? - R Or -replace this option and - the effect of I option is adverse;This option records what there is identical and only key word in replacing a list.
? ?- - Fields-enclosed- By= Char
When ? ? appoints the record of the data in text file, rise with what draw together,The data below a lot of circumstances rises with double quote draw together.The data below acquiescent circumstance is to do not have what be removed by character draw together.
? ?- - Fields-terminated- By=char
The separator between the value that ? ? assigns each data,In the file of full stop space,Separator is full stop.You can appoint the separator between data with this option.Acquiescent separator is to jump case accord with (Tab)
? ?- - Lines-terminated- By=str
? ? this option appoints the travel in text file and travel between the disjunctive string of data or character.The Mysqlimport below acquiescent circumstance is a separator with Newline.You can choose to replace a single character with a string:Go newly or a carriage return.
The option with commonly used command of ? ? Mysqlimport still has - V shows version (Version) ,- P clew inputs a password (Password) etc.
? ?
? ?3) . Example:Guide one is the file of separator with comma

The format of the travel in ? ? file is such:
? ? "1" , "ORD89876" , "1 Dozen Roses" , "19991226 "
? ? our task is to want to guide the data inside this file into the form Orders in database Meet_A_Geek,We use this order:
Fields-terminated-by= of - of Fields-enclosed-by=" of - of Prl of - of ? ? Bin/mysqlimport, meet_A_Geek Orders.txt
? ? commands the likelihood looks this very accurate,After was familiar with when you nevertheless,This is very simple.The first part,Bin/mysqlimport, telling an operating system you want the order that move is the Mysqlimport below Mysql/bin catalog,Option P is requirement input password,Ask you are altering so the password is inputted before the database,The operation rises the meeting is safer.Because we want a list,we used R option is the data in there is the record that repeats only key word to replace a document in medium only key word and file record.We express the data in sheet is not newest,The data in needing to use a document goes updating,Use R consequently this option,In replacing a database already some records.The action of L option is chain when we insert data watch,The operation that when preventing an user to replace a list in us so, has inquire or be changinged to the watch.

...

MySQL data guides derive method and tool

The interpreter states:The partial content that article content comes from one book of Sam's Teach Yourself MySQL In 21 Days,English of By Mark Maslakowski is textual the person that copyright belongs to original work is all,The partial interpreter of Chinese has somewhat the too clear place that original book of; of additions and deletions tells has cutout,The not clear place that tell has add;If have the place with the interpreter's incorrect perhaps misgivings,Ask point out mistakes so that they can be corrected.
Translator:David Euler, SCU. De_euler-david@www.yahoo.com.cn

1) the grammar introduction of.mysqlimport:
Mysqlimport is located in in Mysql/bin catalog,One be Mysql loads (perhaps say to guide) a of data very effective tool.This is tool of travel of a command.Two parameter and many options can offer an alternative.This tool file of a text (Text File) in the database that guides you are appointed and watch.In saying we want to guide data into the watch Custermers in database Meet_A_Geek from inside file Customers.txt for example:Mysqlimport Meet_A_Geek Customers.txt

Notice:Customers.txt is we should guide here the text file of data,And Meet_A_Geek is the database that we should operate,The watch name in the database is Customers,The data format of here text file must agree with the format in Customers watch,Otherwise Mysqlimport command will make mistake.

The name that expresses among them is to guide the first full stop of the file (. ) in front file string,Another example:Mysqlimport Meet_A_Geek Cus.to.mers.txt
So we will guide the content in the file into the Cus watch in database Meet_A_Geek.

In the example above,Use two parameter only,Did not use more option,The option of Mysqlimport introduces below

2) the commonly used option of.mysqlimport introduces:

Option function
- D Or- - Delete new data guides data data is deleted to express all medium information before data table is medium
- F Or- - no matter whether Force encounters a mistake,Mysqlimport will continue compulsively to insert data
- I Or- - Ignore Mysqlimport is jumped over or those have oversight identical and exclusive

The travel of key word,Guide the data into the file will by oversight.
- before data of L Or -lock-tables is inserted, chain watch,Prevented so,When you are updating a database,The inquiry of the user and be affected newlier.
- R Or -replace this option and - the effect of I option is adverse;This option records what there is identical and only key word in replacing a list.
- - when Fields-enclosed- By= Char appoints the record of the data in text file, rise with what draw together,The data below a lot of circumstances rises with double quote draw together.The data below acquiescent circumstance is to do not have what be removed by character draw together.
- - the separator between the value that Fields-terminated- By=char assigns each data,In the file of full stop space,Separator is full stop.You can appoint the separator between data with this option.Acquiescent separator is to jump case accord with (Tab)
- - this option of Lines-terminated- By=str appoints the travel in text file and travel between the disjunctive string of data or character.The Mysqlimport below acquiescent circumstance is a separator with Newline.You can choose to replace a single character with a string:Go newly or a carriage return.The option with Mysqlimport commonly used command still has - V shows version (Version) ,- P clew inputs a password (Password) etc.

3) . Example:Guide one is the file of separator with comma

The format of the travel in the file is such:
"1" , "ORD89876" , "1 Dozen Roses" , "19991226 "
Our task is to want to guide the data inside this file into the form Orders in database Meet_A_Geek,We use this order: Fields-terminated-by= of - of Fields-enclosed-by=" of - of Prl of Bin/mysqlimport -, meet_A_Geek Orders.txt
This command may look very accurate,After was familiar with when you nevertheless,This is very simple.The first part,Bin/mysqlimport, telling an operating system you want the order that move is the Mysqlimport below Mysql/bin catalog,Option P is requirement input password,Ask you are altering so the password is inputted before the database,The operation rises the meeting is safer.Because we want a list,we used R option is the data in there is the record that repeats only key word to replace a document in medium only key word and file record.We express the data in sheet is not newest,The data in needing to use a document goes updating,Use R consequently this option,In replacing a database already some records.The action of L option is chain when we insert data watch,The operation that when preventing an user to replace a list in us so, has inquire or be changinged to the watch.

...

SQLserver database guides the experience of Mysql database

Because of working need,Want to will deposit the data in Sql Server database to guide entirely in Mysql database,Be in on the net related collect data,Find two kinds of methods,Talk about the view to them respectively now.
The first kind is installation Mysql ODBC,Those who use Sql Server derive function,Source of choice Mysql data,Derive directly into what linage occupies,This kind of method is very simple,But have a lot of corrupt practice in the light of actual application,The mainest reflecting is data type problem,Above all,In Sql Server database
Ntext, the data of the data type such as Image cannot be written directly in Mysql database,It is OK to should alter slightly only allegedly,Regrettablly occasionally this dish bird has not thought of how to alter,Next,Because design lieutenant general time to be set into Int in the database in Mysql occasionally model (those who save is time jab) ,Guide in data so after coming over,With respect to meeting occurrence conflict,Again,The field kind that the Mysql data that this kind of method generates expresses is very not right,So this is planted method I feel that this cannot be advocated.

The second kind is to use Php or Asp script to come to those who realize data to guide into the function,This kind of method needs to write a program,But flexibility is big,The operation also is not so difficult,Everything all is in your control,Introduce this method simply now
The Mysql environment that premise condition is you has been built,Build good cause database first,Build all watch structures with Sql statement again,All things is had now,Lack data only.

The data in the User watch that can realize database of the Mydb in Sql Server originally through the Php foot below guides to database of the Mydb in Mysql
%26lt; ?
$cnx = Odbc_connect('web' , 'admin' , the data source name that '123456');//'web' is the Mydb in Sqlserver,The user name that 'admin' is visit Mydb,'123456' is the password that visits Mydb
$cur= Odbc_exec($cnx, 'select * From User' );// opens the User table of database of the Mydb in Sql Server
$num_row=0;
$conn=mysql_pconnect("localhost" , "Root" , "Mysql of 123456");// join
@mysql_select_db('mydb' , $conn) Or
Die(" cannot receive a database repeatedly,Contact with the administrator please!") the Mydb database that;// opens MysqlWhile(Odbc_fetch_row($cur)) // takes out data one by one from the User watch in the Mydb library of Sql Server,If undertake choosing to data,The condition can be added to judge in the Select statement in front
{
$num_row++;
$field1 = Odbc_result($cur, the parameter I(1 here, 2, 3. . ) the I that those who point to is record concentration region,You can choose the ground to undertake choosing somewhat,The value that Fieldi gets corresponding region,Next you can undertake operating to Fieldi
$field2 = Odbc_result($cur, 2);
$field3 = Odbc_result($cur, 3);
$field4 = Odbc_result($cur, 4);
$field5 = Odbc_result($cur, 5);
$field6 = Odbc_result($cur, 6);
The field that pair of Datetime types in Sql Server are here undertakes be changinged accordingly handling,The Int that changeover needs into me
$querystring = "insert Into User
(Id, name, username, password, recdate)Values('$field1' , '$field2' , '$field3' , '$field4' , '$field5')" ;
Mysql_query($querystring, $conn);
}
Function Timetoint($str){
$arr1=split(" " , $str);
$datestr=$arr1[0];
$timestr=$arr1[1];
$arr_date=split("-" , $datestr);
$arr_time=split(" :" , $timestr);
$year=$arr_date[0];
$month=$arr_date[1];
$day=$arr_date[2];
$hour=$arr_time[0];
$minute=$arr_time[1];
$second=$arr_time[2];
$time_int=mktime($hour, $minute, $second, $month, $day, $year);Return $time_int;
}
? %26gt;

Put this paragraphs of script into Sql.php,Carry out on the server,Can get on the server the data in the User watch of database of the Mydb in Sql Server guides the User of database of the Mydb in Mysql goes in the watch.The operation of other watch and this is duplicate,not give uncecessary details.

The data of database of the Mydb in Asp script introducing to realize Sql Server again below guides to database of the Mydb in Mysql
%26lt;%Set Conn=server.createobject("adodb.connection" )Conn.open 'web' , 'admin' , the data source name that '123456' // 'web' is the Mydb in Sqlserver,The user name that 'admin' is visit Mydb,'123456' is the password that visits MydbSet Rs=server.createobject("adodb.recordset" )Sql="select ID, name, username, password, datediff(s, '1970-01-01 00:00:00' , recdate)-8*3600, reid, filename, fileContentType, the Int that this Sql statement realized Filevalue From Senddate" // to change the Recdate field of Datetime type into Unix time jab
Rs.open Sql, conn, 1, 3Set Conn1=server.createobject("adodb.connection" )Conn1.open "myoa" , "Root" , "Q1-d6=7? "Q1-d6=7?? I=1Do While Not Rs.eofField1 = Rs(0)Field2 = Rs(1)Field3 = Rs(2)Field4 = Rs(3)Field5 = Rs(4)Sql1 = "insert Into User(ID, name, username, password, recdate)
Values(%26quot;%26amp;field1%26amp;%26quot; , '%26quot;%26amp;field2%26amp;%26quot;' , '%26quot;%26amp;field3%26amp;%26quot;' , '%26quot;%26amp;field4%26amp;%26quot;' , %26quot;%26amp;field5%26amp;%26quot;) %26quot;
Conn1.execute Sql1Rs.movenextI=i+1LoopRs.closeSet Rs=nothingConn.closeSet Conn=nothingConn1.closeSet Conn1=nothing

%%26gt;

Above is two to use the data that Php script and Asp script express to User to undertake arriving by Sql Server respectively of Mysql guide into meantime I use 2 kinds of evasive methods to avoid Ntext, of Image type data deliver,One kind is Nvarchar(4000) of Ntext field instead,Because of actual condition,The data length of this field in primitive data did not exceed 4000 words,Cut off without occurrence data so,Another method is Image kind data is taken in keeping a file,Save with file form,In putting file way the database,The method sees below:
Function Makeattach(fileContentType, filevalue, i)Select Case FileContentTypeCase "application/msword "Ext="doc "
Case "application/vnd.ms-excel "Ext="exl "
Case "application/vnd.ms-powerpoint "Ext="pps "
Case "application/x-rar-compressed "Ext="rar "
Case "application/x-zip-compressed "Ext="zip "
Case "image/gif "Ext="gif "
Case "image/pjpeg "Ext="jpg "
Case "text/plain "Ext="txt "
Case ElseExt="x "
End SelectIf Ext%26lt;%26gt;%26quot;x%26quot; ThenSet Fso=server.createobject("FileSystemObject" )FName=%26quot;attech%26quot;%26amp;i%26amp;%26quot; . "%26Amp;ext
Dir="d:aTtach "
If Fso.FileExists(Dir%26amp;FName) Then Fso.deletefile Dir%26amp;FName
If FName%26lt;%26gt;%26quot;%26quot; AND NOT Fso.FileExists(Dir%26amp;FName) Then
Set Strm1=Server.CreateObject("ADODB.Stream" )Strm1.OpenStrm1.Type=1 'BinaryStrm1.Write FilevalueStrm1.SaveToFile Dir%26amp;FName, 2
Set Strm1=NothingEnd IfMakeattach=fNameEnd IfEnd Function

This function has 3 inputs parameter,The first ContentType that is a file,The second binary system that is a file is numeric,The third is a variable that can distinguish file name,The suffixal name that puts a document certainly according to ContentType first,Save binary numerical value the file that designates file name namely next,Return file master to output parameter,The database middleman and guarantor that writes returned parameter Mysql as data is put.
Time is hurried,Sum up here first,Some help the person that hopes these characters can need to having,Take some of roundabout way less,Thank you read.:)

...

Install synchronism of MySql data

Mysql offers a database later from 3.23.15 version duplicate function.Use this function to be able to realize two databases synchronism,Mode of principal and subordinate,The function of mutual backup mode.

The setting of duplicate function is in database synchronism the setting of Mysql is reflected in the file.The configuration file of Mysql (it is My.cnf commonly)

Be in below Unix environment / Etc/mysql/my.cnf perhaps is in the My.cnf below the Home catalog of Mysql user.
In Window environment,If C: ??cangue stalking or branch sweeps past ? Y.cnf file to take this to configure a file.When the Winmysqladmin.exe tool moment of moving Mysql,This tool is met a C: ?.cnf of ? of busy of ? cangue stalking or branch names for Mycnf.bak.Found My.ini below Winnt catalog.The Mysql server moment that start can read this to configure a file.In can copying the content in My.cnf to My.ini file so,The configuration file that regards Mysql as the server with My.ini file.

Set a means:

Setting example environment:

Operating system:Window2000 Professional
Mysql:4.0.4-beta-max-nt-log

A Ip:10.10.10.22

B Ip:10.10.10.53

A: ?haddock ?BR>
1. adds the user account with a most synchronous user:


...

MySQL optimizes compendious guideline

One, MySQL is optimized when compile

If you distribute installation MySQL from source code,Should notice,The effect with compile a process to have to function of the following object program main,Compile means differently to may obtain similar target document,But function may differ very big,Because of this,Compiling installation MySQL to suit to choose carefully to compile option well the most possibly according to your applied type.This kind of custom-built MySQL can offer optimum behavior for your application.

Skill:It is better to choose compile implement it is better to mix compile implement option,Such application can raise function 10-30% .(MySQL documentation says so)

1.1, use Pgcc (Pentium GCC) is compiled implement

Should compile implement (Http://www.goof.com/pcg/ ) in the light of move in gallop the program on processor system undertakes optimizing,Compile MySQL source code with Pgcc,Overall performance can rise 10% .If your server is not to use,gallop of course processor,Need not use it,Because it is to be only,gallop the system designs.

1.2, the character set that uses you to want to use only compiles MySQL

The character set that MySQL looks premise differs for amounting to 24 kinds,The data in be inserted with the language of themselves for global user or examining a watch.Save a circumstance to fall however,MySQL installation is possessory these character set,Hot however,Best choice is to point to those who choose a kind of your need.Like,Prohibit removing all other character set beyond Latin1 character set:

--------------------------------------------------------------------------------
%%26gt; . / Configure -with-extra-charsets=none [- - Other-configuration-options]
--------------------------------------------------------------------------------

1.3, compile Mysqld the static state to carry out a file

Compile Mysqld the performance with the static state carries out a file and need not share a library to also can be obtained better.Through following options is being appointed when configuration,But the static state compiles Mysqld.

--------------------------------------------------------------------------------
%%26gt; . / Configure -with-mysqld-ldflags=-all-static [- - Other-configuration-options]
--------------------------------------------------------------------------------

1.4, configuration example

Following configuration command is commonly used at improving performance:

--------------------------------------------------------------------------------
%%26gt;CFLAGS=%26quot;-O6 -mpentiumpro -fomit-frame-pointer%26quot; CXX=gcc CXXFLAGS=%26quot;-O6 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti%26quot; . / Configure- - Prefix=/usr/local- - Enable-assembler- - With-mysqld-ldflags=-all-static- - Disable-shared
--------------------------------------------------------------------------------

...

Undertake data manipulation to MySQL with batch processing

Batch processing is a kind of method that is not seesaw pattern to run Mysql program,The order that uses in Mysql as you is same,You still will use these orders.
? ?
? ? to realize batch processing,You are heavy directional a file arrives in Mysql program,Above all we need document of a text,Bag of this text file contains the text version with the same command that inputs in Mysql with us.
For instance we should insert ? ? a few data,Use include below the file of text (file name is New_Data.sql, of course we are OK also entitle New_Data.txt reachs any other legal names,Differ compose Sql is terminal after wanting surely) :
? ? USE Meet_A_Geek;
? ? INSERT INTO Customers (Customer_ID, last_Name) VALUES(NULL, "Block");
? ? INSERT INTO Customers (Customer_ID, last_Name) VALUES(NULL, "Newton");
? ? INSERT INTO Customers (Customer_ID, last_Name) VALUES(NULL, "Simmons");
The grammar of these sentences above ? ? attention must be correct,And every sentence ends with semicolon.
The USE command above ? ? chooses a database,INSERT command inserts data.
? ?
We want to guide the file above below ? ? in the database,Before guiding, should affirm the database been movinging,It is Mysqld process namely (perhaps persuade Wu,Call below Windows NT " service " ,It is below Unix " process " ) having movinging.
? ? runs the command below next:
P of - of ? ? Bin/mysql%26lt;/ Home/mark/New_Data.sql
? ? inputs a password by clew then,If the statement in the file above does not have a mistake,So these data are guided in the database.
? ?
LOAD DATA INFILE uses to guide from inside the file data arrives in travel of ? ? command database:
You may ask ? ? oneself now,"After all why I should be inputted all these SQL statements in the file,Run them through the program next?"
? ? seems to need much work it seems that so.Very good,You wanted to be opposite probably so.But if you have,record from the Log of all generation in these commands?Now such very marvellous,Hum,The Log that most database can produce the incident in the database automatically to record.And major Log is included has used primitive SQL commands.Because of this,If you cannot from you derive data is used in new Mysql database in present database,So the batch processing that you can use Log and Mysql is characteristic,Come fast and guide conveniently your ground data.Of course,Such with respect to leave out typed trouble.
? ?
? ? LOAD DATA INFILE
? ? this is us those who want the introduction is the last guide data arrives the method in MySQL database.This command and Mysqlimport are very similar,But this method can command to be used in travel in Mysql.That is to say you are OK this order is used in the program of all use API.Use this kind of method,The data that in can using a program, you guide you want to guide.
? ?
Before ? ? uses this order,Mysqld process (service) must have movinging.
Command of the ? ? Mysql that start goes:
P of - of ? ? Bin/mysql
? ? inputs a password by clew,After entering Mysql command successfully to go,The command below the input:
? ? USE Meet_A_Geek;
? ? LOAD DATA INFILE "/home/mark/data.sql" INTO TABLE Orders;
? ? is told simply,Will guide the content in file Data.sql so in expressing Orders,Like Mysqlimport tool,The parameter that this command also has a few to be able to choose.The data that for instance you need to get on your computer guides in long-range database server,You can use the order below:
? ? LOAD DATA LOCAL INFILE "C:\MyDocs\SQL.txt" INTO TABLE Orders;
? ?
The file that the LOCAL parameter above ? ? shows to the file is this locality,The server is the server that you land.
? ? such with respect to leave out use Ftp will upload a file to the server,MySQL was finished for you.
You also can install ? ? the first step that inserts a statement,If you want to label it,be small first step (LOW_PRIORITY) ,So MySQL will when when reading this list without someone else,Just insert data.The order that can use as follows:
? ? LOAD DATA LOW_PRIORITY INFILE "/home/mark/data.sql" INTO TABLE Orders;
? ?
You also can appoint ? ? when whether inserting data,Replace or key is worth the reduplicative in oversight file and data table.The grammar that replaces reduplicative key cost:
? ? LOAD DATA LOW_PRIORITY INFILE "/home/mark/data.sql" REPLACE INTO TABLE Orders;
The sentence above ? ? looks a bit awakward,But put key word in what let you to analyse however implement understandable place.
? ?
The described a file to option format below ? ? ,These option also are what to can use is in in Mysqlimport tool.They differ a bit it seems that here.Above all,Should use FIELDS key word,If use this key word,MySQL is analysed implement the hope sees have an option below at least:
? ? TERMINATED BY Character
? ? ENCLOSED BY Character
? ? ESCAPED BY Character
It is same that these ? ? key word and their parameter follows the use in Mysqlimport. The
The separator of field of description of ? ? TERMINATED BY,Tab character is below acquiescent circumstance (\t)
The character since the draw together that what ? ? ENCLOSED BY describes is a field.Have each field with quote draw together for example.
The escape character that ? ? ESCAPED BY depicts.Acquiescent is to counter some of thick line (Backslash:\ ) .
The Mysqlimport jussive case in front still is used below ? ? ,Use statement of LOAD DATA INFILE to guide same document in the database:
? ? LOAD DATA INFILE "/home/mark/Orders.txt" REPLACE INTO TABLE Orders FIELDS TERMINATED BY ' , ' ENCLOSED BY '"';
? ?
There is a characteristic in there is tool of a Mysqlimport in statement of ? ? LOAD DATA INFILE:
? ? LOAD DATA INFILE can list a file to guide by what appoint in the database.
When the one part content that ? ? wants a data when us guides,This characteristic is very important.Say for example,When we should upgrade to MySQL database from Access database,Need adds a few columns (row / field / Field) in MySQL database,In order to get used to a few additional need.
? ? this moment,The data in our Access database remains practicable,But the column because of these data (in Field) and MySQL match no longer,Can no more use Mysqlimport tool because of this.Nevertheless,We still can use LOAD DATA INFILE,The example below showed how to designation column (guide in Field) data:
? ? LOAD DATA INFILE "/home/Order.txt" INTO TABLE Orders(Order_Number, order_Date, customer_ID);
? ?
? ? is seen like you,The column that we can appoint need (Fields) .The field that these designation still is with bracket draw together rises,By comma space,If you were omited among them any,MySQL will remind you
? ?
? ? Importing Data From Microsoft Access (guide from inside Access into data,Slightly)

...
« 首页...« 1 2 3 4 5 6 7 8 9 »...尾页 »