Solved

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

Posted on 2004-10-08
2
559 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 500 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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