LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-01-2010, 01:57 PM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
Problem importing text files into a mysql database


Hi there --

We have an archive server where the administrator, via a web interface, can import text files into a mysql database. The files are typically local to the machine. The operating system of the server is CentOS 5.4, and that of the mysql database is 5.0.77.

The database was originally on another server which was replaced by the one that is currently in use. The migration of the database from the older server involved creating a dump file, copying the file to the new machine, and importing it into the database. The version of the mysql database on the previous server was 5.0.45.

The problem that has started to occur is the following: When the administrator goes through the motions of importing a text file to the database, the text does not get imported even though there are no error messages appearing on-screen or in the mysqld.log file. The administrator can see what is already in the database, but he cannot add to it.

The web interface to the database utilizes perl modules and cgi files. I ran the cgi files from the command line to see if there were any error messages. There were none. The perl modules that were on the previous server were copied to the new server with the permissions kept intact. I also verified the user and database permissions on the new server match those on the older server.

I am at a loss as to why this is occurring, and I would appreciate any help I can get on this. I have enclosed the files that are involved with the importation of the text file into the database as a single text file attachment. The files are all cgi files with the exception of the last file being the perl module. The names of the files in the order of their appearance within the text file are the following:

Quote:
addarchive.cgi
addarchivenew.cgi
addarchiveold.cgi
addarchivesql.cgi
addarchivesqlnew.cgi
addarchivesqlold.cgi
main.cgi
searcharchive.cgi
searcharchivesql.cgi
WebDBdicom.pm
If there is need of further information, please let me know. Thanks in advance.
Attached Files
File Type: txt combined files.txt (41.8 KB, 12 views)
 
Old 06-01-2010, 02:05 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Can you import the database dumps using phpmyadmin ? Or are the formats wrong ?

Main reason being to eliminate the new database's structure or state from the problem.
 
Old 06-01-2010, 03:21 PM   #3
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I haven't had a chance to install phpmyadmin, but I did try the mysqlimport command. Unfortunately I am getting a syntax error when I run the command.

The command syntax that I am using is the following:

Code:
mysqlimport archivedicom /home/ahk/RODICOM_04may10-1.txt;
Where archivedicom is the name of the database, and full pathname to text file in question immediately follows. I also tried this command using just the filename of the text file instead of including the entire path to the file.

Whenever the command is run, the following error message appears:

Quote:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqlimport archivedicom /home/ahk/RODICOM_04may10-1.txt' at line 1
I checked the mysql homepage, and it appears my syntax is correct. What am I missing? thanks.
 
Old 06-01-2010, 11:03 PM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
After looking at those cgi scripts I see nothing that imports data from a db dump into a dbase using a standard import format. So the question is, how were these dump files created ? Were they dumps of tables or the entire dbase ?

Also, the syntax for mysqlimport requires the option --local and mysqlimport expects there to be a table named RODICOM_04may10-1. Does such a table exist ? You do not need a semi colon if this command is run from the shell, but you do need to specify the user and password for the database you are importing to.

If it was an entire dbase dump then use mysql -u user -p<password> dbasename < dbase-dumpfile to import it.
 
Old 06-02-2010, 01:02 PM   #5
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

I tried running the mysqlimport utility again using the following command syntax:

Code:
mysqlimport --local --user xxx --password xxx archivedicom backupdicom.txt;
I made sure to change the name of the file from RODICOM_04may10-1.txt to backupdicom.txt. The latter name reflects the name of the table within the archivedicom database. The command was run with just the filename as well as the full pathname: /home/ahk/backupdicom.txt.

I logged into the database as root and another user that has full access to the database. The command was run while either connected to the particular database, archivedicom, or when just logged into the database. The mysqlimport utility would not run unless I put the semi-colon at the end of the line.

The command failed in all instances with the 1064 error appearing on-screen.

Regarding the cgi scripts: They don't import data from a dump file into the database. Rather, they import data from a text file, and add it to the database. Listed below is an excerpt from one of the text files:

Quote:
04-May-10

The patients listed below are those that were archived from the Galaxy server H:\dicomserver\data directory.

They were written to two LTO-4 tapes:

DQH213L4 Data Protector 6.0 backup to be kept in the LTO-4 library.
DQH214L4 Data Protector 6.0 backup to be kept offsite.

12/16/2009 05:19 PM <DIR> 0000001
06/24/2009 04:56 PM <DIR> 000001
12/29/2009 06:55 PM <DIR> 000011
12/29/2009 06:37 PM <DIR> 00003
04/21/2010 03:58 PM <DIR> 00004
04/21/2010 03:57 PM <DIR> 00005
02/23/2010 10:40 PM <DIR> 000054888
Sorry about the confusion.
 
Old 06-02-2010, 02:12 PM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
You shouldn't need to be logged into to the database to run mysqlimport. mysqlimport is a shell command not a mysql shell command. That's why you specify user and password on the command line.

Without knowledge of the contents of the dump files, the purpose of the dbase or the original dump command, we have no way of knowing what type of dump was done.
Groping in the dark so to speak.

What happened to the person who originally set this up ? They are in a much better position to sort this out than I am.
 
Old 06-02-2010, 02:15 PM   #7
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. The author of the database is currently unavailable, but hopefully will be back in a week.

As far as the contents of the dump file is concerned, I can provide the file in question, or is/are there specific parts in it from which you need further information?
 
Old 06-02-2010, 02:32 PM   #8
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I would wait for the original author if I were you. If they were never coming back then it would be different but a week is not a long time to wait.
 
Old 06-02-2010, 02:35 PM   #9
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Fair enough...although this issue is going to be an 'itch' that is going to drive me crazy until it is resolved.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a csv file into a mysql database kaplan71 Linux - Server 13 09-18-2009 06:13 PM
need to convert text files into mysql database zafar466 Linux - Software 1 08-28-2007 12:53 AM
PHP Script for Importing vCards into a MySQL Database? amocjr Linux - Software 1 01-20-2007 03:54 PM
Problem importing database back to MySql shubb Programming 3 11-29-2005 01:36 PM
MySQL: Importing a database from an XML file concoran General 0 09-08-2003 02:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration