11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 38 • IMPORTING AND EXPORTING DATAwww.it-ebooks.infoOnce the import is completed, the product_reviews table will look like this:+------------+---------------------------+--------------------------------+| comment_id | email | comment |+------------+---------------------------+--------------------------------+| 43 | jason@example.com | I love the new Website! || 44 | areader@example.com | Why don't you sell shoes? || 45 | anotherreader@example.com | The search engine works great! |+------------+---------------------------+--------------------------------+Choosing the Target DatabaseYou might have noticed that the preceding example referenced the target table but did not clearly defi<strong>net</strong>he target database. The reason is that LOAD DATA INFILE assumes that the target table resides in thecurrently selected database. Alternatively, you can specify the target database by prefixing it with thedatabase name, like so:LOAD DATA INFILE 'productreviews.txt' into table corporate.product_reviews;If you execute LOAD DATA INFILE before choosing a database, or without explicitly specifying thedatabase in the query syntax, an error will occur.Security and LOAD DATA INFILEUsing the LOCAL keyword, it’s possible to load a file which resides on the client. This keyword will cause<strong>MySQL</strong> to retrieve the file from the client computer. Because a malicious administrator or user couldexploit this feature by manipulating the target file path, there are a few security issues that you shouldkeep in mind when using this feature:• If LOCAL is not used, the executing user must possess the FILE privilege. This is dueto the potential implications of allowing the user to read a file residing on theserver, which must either reside in the database directory or be world-readable.• To disable LOAD DATA LOCAL INFILE, start the <strong>MySQL</strong> daemon with the --localinfile=0option. You can later enable it as needed from the mysql client bypassing the --local-infile=1 option.Importing Data with mysqlimportThe mysqlimport client is just a command-line version of the LOAD DATA INFILE statement. Its generalsyntax follows:mysqlimport [options] database textfile1 [textfile2 ... textfileN]724

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!