?
Solved

How to upload data to MySql databse (phpMyAdmin, Yahoo store host)

Posted on 2004-10-08
2
Medium Priority
?
560 Views
Last Modified: 2008-03-06
How do I upload data to my MySql database? Using phpMyAdmin, I see how to do a dump (getting data out) but not how to get data in.

I've tried using the feature "insert data from a textfile into a table", which allows me to browse to a local file, but the filename arrives blank into the SQL-query and I get the following statement, with an error:  

LOAD DATA LOCAL INFILE '' INTO TABLE `Customer` FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'

MySQL said:
File '' not found (Errcode: 2)

I have MySQL installed locally.  Can I maintain my databases from here?  

My goal is to sync our local customer and product info with my on-line tables.

Alex
0
Comment
Question by:idolcemia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Umesh earned 2000 total points
ID: 12265166
Hi,

( I have taken below text from a forum)

I think it has to do with PHP running in safe mode, or it could be that the temp directory has not been defined in the ini file on the server.
In PHPMyAdmin you have to upload a file to import into MySQL. If PHP is installed in safe mode, then this is not permitted (it is not permitted to access files in the temp directory). Try the function phpinfo() and you'll see an overview of PHP settings and whether or not a temp directory has been set.

Try to contact your serveradministrator and ask if they can install PHP without the save mode. I had the same thing once.

>>I have MySQL installed locally.  Can I maintain my databases from here?  

Ofcource  yes..

For security reasons, when reading text files located on the server, the files must either reside in the database directory or be readable by all. Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege. See section 5.5.3 Privileges Provided by MySQL.



To read the comma-delimited file back in, the correct statement would be:

mysql> LOAD DATA INFILE 'data.txt' INTO TABLE Customer FIELDS TERMINATED BY ',';

To read the tab-delimited file back in, the correct statement would be:

mysql> LOAD DATA INFILE 'data.txt' INTO TABLE Customer FIELDS TERMINATED BY '\t';


If you specify a FIELDS clause, each of its subclauses (TERMINATED BY, [OPTIONALLY] ENCLOSED BY, and ESCAPED BY) is also optional, except that you must specify at least one of them.

If you don't specify a FIELDS clause, the defaults are the same as if you had written this:

FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\'

If you don't specify a LINES clause, the default is the same as if you had written this:

LINES TERMINATED BY '\n' STARTING BY ''


You can check these if you need more info on this..

http://dev.mysql.com/doc/mysql/en/Loading_tables.html
http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html


Hope This Helps!






0
 

Author Comment

by:idolcemia
ID: 12267502
I ran phpinfo() and discovered the following:

safe_mode=Off
upload_tmp_dir=tmp, which didn't exist so I created it.

And now it works!  It uploads my local file to /tmp, reads it into the table, and deleted it (apparently, because /tmp is empty when the operation's through.)

Thanks a lot!

-Alex
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question