? ? MySQL has a lot of to be able to guide into the method of data,However these just are counted according to transmitting medium half,Another it is commonly derive from inside MySQL database data.Have a lot of reasons we need to derive data.A main reason is to be used at backup database.The cost of data often costly,Need handles them carefully.Often backup can be helped prevent valuable data ground to lose;Another reason is,Perhaps you hope to derive data will share.In the world that this IT grows ceaselessly,Share data to become commonner and commonner.
The large database that says Macmillan USA safeguards the works that protecting to will be published for example.This database is shared between a lot of bookshops,Such they know what book will be published very quickly.Hospital more and more the trend uses the anamnesis that do not have paper to record,Such these anamnesis can follow you at any time.The world becomes smaller and smaller,Information also is shared increasingly.In having a lot of, derive data gets a means,They follow guide data is very similar.Because of,After all,These are a kind of fluoroscopy gets way only.The data that the data that derives from the database guides from another end namely.We do not discuss other databases to derive variously here the method of data,How do you come to the society realize data to derive with MySQL.
? ?
? ? uses Mysqldump:
? ?
? ? (Mysqldump command is located in in Mysql/bin/ catalog)
Tool of ? ? Mysqldump a lot of sides are similar and opposite the tool Mysqlimport of action.They have a few same option.But Mysqldump can do more businesses.It can lade whole database in an alone text file.This file bag contains all rebuilding the SQL that your database place needs commands.This command obtains all mode (Schema,There is an explanation from the back) and change its into DDL grammar (CREATE statement,Namely the database defines a statement) ,Obtain all data,And found INSERT statement from inside these data.All this tool in the database designs you are inverse.Because all things are included,arrived in file of a text.This text file can use a simple batch processing and statement of an appropriate SQL to guide in returning MySQL.This tool makes a person fab ground is simple and fast.Will never have the least bit let poll be fond of ground place.
? ?
? ? because of this,If you resemble lading,the content of whole database Meet_A_Geek arrives in a file,Can use the order below:
P Meet_A_Geek of - of ? ? Bin/mysqldump%26gt;MeetAGeek_Dump_File.txt
? ?
Does this statement also allow ? ? do you appoint a watch to undertake Dump(backs up / derive / lade? ) .If you are the in expressing Orders whole content that hopes a database Meet_A_Geek is medium only,derive to a file,Can use the order below:
P Meet_A_Geek Orders %26gt;MeetAGeek_Orders.txt of - of ? ? Bin/mysqldump
? ?
? ? this exceedingly agile,The record that you can use WHERE subordinate clause to choose you to need even derives in the file.Should achieve such goal,Can use be similar to the command below:
Where="Order_ID of - of P of - of ? ? Bin/mysqldump%26gt;2000" Meet_A_Geek Orders%26gt;Special_Dump.txt
? ?
Tool of ? ? Mysqldump has many option,Partial options is expressed as follows:
? ? option / Option action / Action Performed
? ?- - Add-drop-table
? ? imposes sentence of DROP TABLE IF EXISTS before this option will express in each,Can assure to guide when answering MySQL database, won't make mistake so,When because guide every time,be being answered,Can check a watch to whether exist above all,Exist to be deleted
? ?- - Add-locks
This option meets ? ? bind a LOCK TABLE and UNLOCK TABLE statement in INSERT statement.This prevents to record the operation that is guided other user undertakes to the watch when the database again in these
? ?
? ? - C Or - Complete_insert
? ? this option makes Mysqldump command produces INSERT statement to add the above-listed to each (Field) name.Should derive data guide this option when another database is very useful.
? ?- - Delayed-insert adds DELAY option in INSERT command
? ? - F Or -flush-logs uses this option,Carrying out before deriving will the Log of refresh MySQL server.
? ? - F Or -force uses this option,Although have mistake happening,Still continue to derive
? ?- - Full in the sentence that this option also imposes additional information to CREATE TABLE
? ? - L Or -lock-tables uses this option,Derive when expressing, the server will add a lock to the watch.
? ? - T Or -no-create- Info
The Mysqldump that this option makes commands ? ? not to found CREATE TABLE statement,This option needs data only in you and do not need DDL (the database defines a statement) when very convenient.
? ?
? ? - the Mysqldump that this option makes commands D Or -no-data not to found INSERT statement.
? ? when you need DDL statement only,Can use this option.
? ?- - the option of the file that Opt this option will open all meetings to raise a file to derive speed and creation can guide more quickly.
? ? - Q Or -quick this option makes MySQL won't whole derived content reads in memory to be carried out again derive,Write when be read however guide in the file.
? ? - this option will found T Path Or -tab = Path two files,A file includes DDL statement to perhaps be expressed found a statement,Another file includes data.DDL file name Table_name.sql, data file name Table_name.txt. Method name is the catalog that deposits these two files.Catalog must have existed,And jussive is used person the privilege that has pair of files.
? ?
? ? - W "WHERE Clause" Or -where = "Where Clause "
? ? if in front what tell,You can use this one option to choose will put derive the data of the file.
? ?
? ? assumes you need to express the account that should use in sheet to build a file for,The manager should look this year (2004) all order (Orders) ,They are not interested in DDL,And need a document have comma space,Because guide very easily so,arrive in Excel.To accomplish this individual thing,You can use the sentence below:
Where %26quot;Order_Date %26gt;='2000-01-01' of - of P of - of ? ? Bin/mysqldump %26quot;
Fields-terminated-by= of - of No-create-info of - of Tab = /home/mark of ? ? -, meet_A_Geek Orders
This will get ? ? the result that you want.
? ?
? ? Schema:Mode
? ? The Set Of Statements, expressed In Data Definition Language, that Completely Describe The Structure Of A Data Base.
? ? defines the statement market that the language will come convey one group with data, the structure that this statement collect described a database thoroughly.
? ?
? ? SELECT INTO OUTFILE:
? ? if you feel Mysqldump tool is insufficient cruel,Use SELECT INTO OUTFILE, the order that MySQL offers to have adverse effect with command of LOAD DATA INFILE likewise,This is command of SELECT INTO OUTFILE,These two place that command the likeness that has a lot of.Above all,They have all option almost identical.You need to finish now in front with the function that Mysqldump fulfils,Can the measure below according to undertakes operating:
? ?
? ? 1. Ensure Mysqld process (service) having movinging
? ? 2. Cd /usr/local/mysql
? ? 3. Bin/mysqladmin Ping;/ / if this sentence has not been connected,Can use this:Mysqladmin -u Root -p Ping
? ? Mysqladmin Ping is used at detecting the condition of Mysqld,Is Alive specification is moving,Make mistake need user name and password possibly.
? ? 4. The MySQL that start monitors a program.
? ? 5. P Meet_A_Geek of Bin/mysql -;/ / enter Mysql command to go,And open database Meet_A_Geek, need inputs a password
? ? 6. In command travel,Input a command:
? ? SELECT * INTO OUTFILE '/home/mark/Orders.txt'
? ? FIELDS
? ? TERMINATED BY = ' , '
? ? FROM Orders
? ? WHERE Order_Date %26gt;= '2000-01-01'
? ?
? ? pressed Return in you (carriage return) later,The file was founded.The SELECT statement with this regular like sentence,Just weigh the output that considers screen directional arrived in the file.This imply this advanced inquiry that you can use JOIN to realize much watch.This characteristic also can be used as generator of a forms for reporting statistics.
? ?
? ? example says,You can combine the method that discusses in this one chapter to produce an absorbing inquiry,Try this:
? ?
? ? builds a text file that the name is Report_G.rpt in Mysql catalog,Join the travel below:
? ? USE Meet_A_Geek;
? ? INSERT INTO Customers (Customer_ID, last_Name, first_Name)
? ? VALUES (NULL, "Kinnard" , "Vicky");
? ? INSERT INTO Customers (Customer_ID, last_Name, first_Name)
? ? VALUES (NULL, "Kinnard" , "Steven");
? ? INSERT INTO Customers (Customer_ID, last_Name, first_Name)
? ? VALUES (NULL, "Brown" , "Sam");
? ? SELECT Last_Name INTO OUTFILE '/home/mark/Report.rpt'
? ? FROM Customers WHERE Customer_ID%26gt;1;
? ? affirms Mysql process is moving next,And you are in Mysql catalog,The command below the input:
? ? Bin/mysql%26lt;Report_G.rpt checks you to name the file that serves as output,The last name that this file will include all clients that you input in Customers watch.Be seen like you,You can use what acquire today to guide / derive (Import/export) the method will help get forms for reporting statistics.
...