Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Import Data From Shell Script


I've a comma separated file and would like to use "LOAD DATA LOCAL INFILE..." inside a shell script to import data into a table. Basically, I want the script to connect to database, complete import using "LOAD DATA..." and exit.

I understand, rows can be inserted one by one using database handles but I'd like this to be done using "LOAD DATA..." functionality.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Extracting Field Data And Putting Each Field Into A Shell Variable?
In a MySQL query on the database (one table with 15 variable length fields,
I want to put each field into a Bash variable so that I can handle each
field as an entity.

The query I have is something like this:
mysql -e "use $database; select field1, field2, field3..., from Table1 where
fieldN like '%something%';"

can I / How do I do something like:
mysql -e "use $database; select field1,..., var1=field1, var2=field2,....;"

do
stuff with var1, var2...,
done

LOAD DATA INFILE To Import Data Exported From A MS Access Xp
I am trying to use LOAD DATA INFILE to import data exported from a MS Access Xp table. But all i get in the date field is 00:00:00, as Access exports DATE and TIME and MySQL seems to use just the TIME portion of this.

Is there any way to ahve MySQL import just the DATE portion or is there any way to have Access export only the DATE portion?

Import Data
I am using 5.0.26, community version

The sql file is at c:db.sql

I tried

mysql -u root -p 11111 db < c:db.sql (or enclosed by '', ``)

does not work

mysql -u root -p db < "c:db.sql" (or enclosed by '', ``)

does not work

mysqlimport db < "c:db.sql" (or enclosed by '', ``)

does not work.

Import Data
we have designed an application which contacted with a MySQL database. A client of ours wants to pre-collect data to a Windows-based database like MS SQL, or Microsoft Access. How it is possible to import these data into the MySQL database successfully and with no problems? Also, the character encoding is set to Unicode UTF-8. Which database supports Unicode in order to eliminate possible conflicts?

Import Data
how can i a import data to mysql from such as sql server 2000 or acces ?

Import Old Data To New
My machine was down before, fortunately I have back up the whole
/usr/local/mysql directory. Now I have setup a new mysql on a new
machine, how can I import the old data back to the new database??

My old mysql version: mysql-3.22.32
new mysql version: mysql-max-4.0.3-beta-sun-solaris2.7.sparc

I used to run the mysql like this:

/usr/local/mysql/bin/mysql abc

should I add the user abc to my new database first? and how?

Import Data
how can i import data from sql server 2000 to mysql ?
and please give some site to download mysql utilities ?

Import Data
I am import data from csv with sqlyog, but always have warnings and I can´t import it.

My configuration is:

- Terminated By: ;
- Enclosed by: ;
- Escaped by: ;

- Fields terminated by: ;
- Fields enclosed by: ;

Import A Bunch Of Data In CLI
I am able to login fine via ssh and then I can get into mysql fine via CLI. My problem is that I need to import a 100MB file into a specific database. What should I do?

Need To Import Data Into Table
Newbie here needing to import data into a dbase file table named "template". The file containing this data is "template.dump".

How To Export Or Import Data
how to import data from mysql to another database. & how to export data from another data base to mysql.

Import Data From MSSQL
I have two systems, one using MSSQL and one using MySQL. On a daily basis, I need to import information from tables on the MSSQL database to a table on the MySQL database.
What's the easiest way to do this?

Error Import Data
I exported data with mysqldump, and now i want to import it in another pc, mysql version same. but i got error:

ERROR 1064 (42000) at line 57: 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 ''ADTIVAVELDTYPNTDIGDPSYPHIGIDIKSVRSKKTAKWNMQNGKVGTAHIIYNSVDKRLSAVVSYPNADSATVSYDV' at line 1

how i could fix it?

Trying To Import Data From Csv Into Table
I am trying to use mysqladmin import tool to import data into a table.

I used mysqladmin to export a table in a csv excel format. I then opened that spreadsheet and filled in a bunch of info.

Now I am trying to import that spreadsheet back into the table, but everytime I do I get an error: Invalid field count in CSV input on line 1.

I am using the import tool using csv as the format, and I am not changing any of the options...

MySQL - 4.1.18-standard-log
Protocol version: 10
phpMyAdmin - 2.8.0.2

Import Differantial Data
Everyday day, i produce a text file (f1) nearly the same i produced the day before (f2) that i'd like to import into a mysql table (t1). I could use LOAD DATA with "replace" option but it doesn't suit me cuz it would run all lines from f1.

I would like first to create a differential file from f1 and f2 that would be f3. Then, i only need to import f3 in mysql. I guess i could use the diff and/or the grep commands from linux. Someone can give me some hints or links ?

Import Data From OpenAccess
I have a client using a program written in OpenAccess 4 in 1987 (this is still a DOS based program). We need to convert the data (saved as a df file) to Mysql. Does anyone have a tool that will do that? I can look at the data with notepad, put it has a lot of extra characters in it.

Data Import Error
I have a table with 82 columns, and l load data into it from a delimitted file that doesn't always have data for all of the columns, 70% of the file will only have data for the first 60.
In version MySQL version 4.1.7 this wasn't a problem, but it is in version 5.0.18.
I get this error:
Row 1 doesn't contain data for all columns, when using table..
- this happens with mysqlimport as well as load data infile.
In either scenario I'm using W2K3.

Split/Import Data
I have tables from several different DB's (dbaseIII, Access etc..) that I need to bring into Mysql. I can convert the tables to a Mysql format without any problems but I need to merge and/or split almost all of the tables.
Many of them have address information to be consolidated, order information to be separated, duplicates removed etc..
Does anyone know of a gui to help out on this? Something I can visually map old fields to fields in the new tables?

Import / Export Data
I have some .db files containing a lot of data that I want to 'port' to my newly constructed MySQL database. Please advise some hints or suggestion of how to deal with that.
Is it possible to export the tables from .db file to csv and import it to my new database?

Import Data Into Mysql
is there a way around it, other than scrubbing the data ?
currently, the dates are in mm/dd/yyyy format
if i want to use in import file with fields that have this format, is there any way of applying a conversion to that field on the fly ?

Import Access Data
I have a database that contains information on items for sale, prices, etc. Every few months or so, I need to import data from an access database, to do the following:
- insert any new items from the access database into the mysql database
- update any of the current items with new information (such as price)
I've done a good bit of searching on this, but most of the answers here revolve around a one-time import...this is something that needs to happen regularly.

Import Data Via Ssh Into An Existing Table
I want to import data from several .sql files into an existing database, into one table.

I tried using the following command:
mysql -e [sqlfile] [db_name]

But the problem was when I imported the next file, it would overwrite the previous imported data.

Could anyone let me know how to do this correctly, please?

Import Data From A Binary File
I have a binary file that contains data that was exported from Microsoft SQL. I have the details regarding the various columns that are contained in the file.

I am not sure if MySQL can actually import the data from such a file and load the contents in a table in a text format. Currently this is the only way that the person I am dealing with can provide the data.

Import CSV File With Numeric Data
I am trying to import a CSV file which was exported from another mysql database with comma separation and quote delimeters.  A numeric column is enclosed in quotes and cannot be directly imported into the target table since it is now a string.

How should I import this data?  I have tried to import it to an intermediate table with the id column defined as a varchar but I have been unable to convert that value back to a number.

Import A Csv To Update Only Certain Rows Of Data?
I have an existing mysql table and a csv. I want to import the csv into the table, but it is at a different sort order. There are too many records to sort my csv by hand to match. There is a common 'cd_code' field that both have.

Is it possible to import a csv to the table so that each row of the csv is inserted in the correct row of the table, based on the common 'cd_code' field?

For example, if I sorted by cd_code asc, it would match the csv, but how to I import the csv into a particular sort?

Data Import From Text File
When I try to import a text file with new data for an existing
table I get the error "1148 - the used command is not allowed
with this MySQL version."

I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5.
Both these GUI programmes have an "import from text file" command
which I have used successfully several times to add entries to
this table before - running just this MySQL version. I have
structured the data in the text file in just the same format as
previously.

Both these programmes are connecting to the database successfully
now and will display the contents of the existing table data and
strcutre of the database etc (despite an earlier connection
problem which seems to have been solved spontaneously).

But both now deliver exactly this error message (and therefore I
assume it is MySQL and not the interface programmes which is
doing it).I cannot see that I am doing anything different.

I have MySQL 4.0.12 on Windows ME PC with a local Apache server
and PHP.

Import Old Data To New Mysql Database
My machine was down before, fortunately I have back up the whole
/usr/local/mysql directory. Now I have setup a new mysql on a new
machine, how can I import the old data back to the new database??

My old mysql version: mysql-3.22.32
new mysql version: mysql-max-4.0.3-beta-sun-solaris2.7.sparc

I used to run the mysql like this:

/usr/local/mysql/bin/mysql abc

should I add the user abc to my new database first? and how?

Import Non Normalized Excel Data
So I've got all of my data in csv. Should I import into MySQL directly and then attempt to normalize, or should I try to normalize first, creating individual tables and then import my data.

One current problem I am having with the latter is I've got one column with 10k rows. Of those 10k there are 3k unique values. Manually completing find and replace is going to be a chore (3k is less, but still a bit more than I care to do). Is there something built into MySQL that'll help speed things up a bit?

I Want To Import My Data From Access Into My MySQL DB Online
I have a MySQL database which i access/modify/interact with via PHPMyAdmin.

I have a table with about 20 fields and 609 rows which i need to import into my MySQL database. not all of the fields are the same, not all need to be imported, and all of the field names are different in my MySQL db.

Is there a software i can get to make this process easier. or can i export the access table to some format and import it by specifying what datafields from the access table map to what datafields in the mySQL table?

I've posted a similar request recently, but this one is much simpler. just need to get some data out of access and into mysql.

Would great appreciate any help or software referrals etc.

Much love and a merry xmas

#1064 MySQL Error On Data Import
I know this has to be a simple problem, but it is driving me mad. PHPMyAdmin will allow me to import a SQL insert one line at a time no problem, but when I attempt to import more than one at a time it give me an error saying that my syntax is incorrect. I have tried to import the entire database and it just runs until the 300 sec time out. This wouldn't be so much of a problem to do it one line at a time, but my database is almost 4000 lines in length. Here is the error:

#1064 - 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 'INSERT INTO `contact_images` VALUES (2,1,'alcohol_10.jpg')
INSERT INTO `contact' at line 2

PHP

CREATE TABLE `contact_images` (
  `id` int(11) NOT NULL auto_increment,
  `cat_id` int(11) NOT NULL default &#390;',
  `path` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


and here is a small example of what the data is:


PHP

INSERT INTO `contact_images` VALUES (1,1,'alcohol_1.jpg')
INSERT INTO `contact_images` VALUES (2,1,'alcohol_10.jpg')
INSERT INTO `contact_images` VALUES (3,1,'alcohol_11.jpg')
INSERT INTO `contact_images` VALUES (4,1,'alcohol_12.jpg')
INSERT INTO `contact_images` VALUES (5,1,'alcohol_13.gif')


Like I said, it will allow me to insert each line one by one.. but when I try to do more than one at a time it gives me the error. I have been searching around about the #1064 error and a lot of what I am reading seems to point at the CHARSET, I have tried multiple types of CHARSETS, but I just cannot figure out what the issue is with this.

I was told to try and import the entire database via SSH and that didn't work either.

I am running MySQL version 4.1.21 and PHPMyAdmin 2.8.2.4.

I must be totally missing the issue on this. Can anyone see a problem with me database structure/data?

Easiest Way To Export And Import Data From MySQL?
I wonder what is the easiest way to export data in some kind of text file, edit it in text editor and then import back to MySQL? Is there such software?

I'm asking this because I need to export one table to text file and give it to tranlsator. Then I need to import it back to MySQL.

LOAD DATA INFILE - Problems Trying To Import CSV
mysql> load data local infile '~/Desktop/sdata.csv' into table sdata
-> fields terminated by ','
-> (name, lat, long);

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 'long)' at line 3

I'm trying to import this simple csv file into a table on MySQL and I can't seem to get it to work, I've been reading the forums and searching google and it looks like I'm doing everything correct. I'm sure that I'm missing something! Any advice would be greatly appreciated.

for background the table was created with a Ruby Migration:

class Newmig < ActiveRecord::Migration
def self.up
create_table :sdata do |t|
t.column :name, :string
t.column :lat, :integer
t.column :long, :integer
end
end

def self.down
drop_table :sdata
end
end

Problem With Data Import From Text File
When I try to import a text file with new data for an existing
table I get the error "1148 - the used command is not allowed
with this MySQL version."

I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5.
Both these GUI programmes have an "import from text file" command
which I have used successfully several times to add entries to
this table before - running just this MySQL version. I have
structured the data in the text file in just the same format as
previously.

Both these programmes are connecting to the database successfully
now and will display the contents of the existing table data and
strcutre of the database etc (despite an earlier connection
problem which seems to have been solved spontaneously).

But both now deliver exactly this error message (and therefore I
assume it is MySQL and not the interface programmes which is
doing it). I cannot see that I am doing anything different.

I have MySQL 4.0.12 on Windows ME PC with a local Apache server
and PHP.

PS I sent a long message about this and a connection problem
yesterday which was not succint enough.

How To Import Data Into Existing Rows Of A Table?
I have moved 665 records off of Filemaker into mysql-4.0.18. I had a
great deal of trouble exporting a text field, possibly because it had
control characters that interferred with my field delimiter (also it
was from a Mac, and I'm new at this.)

So I have a table called invoices and another table called tasks, that
has only an invoice number and the work billed on that invoice number.
To see the work billed along with the other invoice data I have to do
a join, and this works but is clumsy for me. Since tasks.work is a
text field of 'infinite' variety I don't see the sense of keeping it
in a separate table like I would with clients' info; it belongs *in*
the invoice table, not just with it.

Is it possible to import this text data into a field in the invoice
table? I've messed around with this but it always appends the data as
new records. Perhaps I was doing an insert back then. Is the answer
something like 'load data infile 'workdone.csv' into invoices
(workdone);'

The invoices table was filled in a certain order (by invoice number)
and the workdone.csv was exported in the same order, so each invoice
row should get its correct text.

Is this a good thing, or am I thinking too 'flat-file-ish'?

Import Data From .txt File Into MySQL Table
i have text files which are generated daily and stored in a folder on the C: drive. I was wondering what would the mySQL command be to import that data into a mySQL table. The text file does not have a header with the field names so would i have to make that table first with the desired columns?? Also, does the file have to be in the databse directory or can it be anywhere on the machine??

How To Import Data Into Existing Rows Of A Table?
I have moved 665 records off of Filemaker into mysql-4.0.18. I had a
great deal of trouble exporting a text field, possibly because it had
control characters that interferred with my field delimiter (also it
was from a Mac, and I'm new at this.)

So I have a table called invoices and another table called tasks, that
has only an invoice number and the work billed on that invoice number.
To see the work billed along with the other invoice data I have to do
a join, and this works but is clumsy for me. Since tasks.work is a
text field of 'infinite' variety I don't see the sense of keeping it
in a separate table like I would with clients' info; it belongs *in*
the invoice table, not just with it.

Is it possible to import this text data into a field in the invoice
table? I've messed around with this but it always appends the data as
new records. Perhaps I was doing an insert back then. Is the answer
something like 'load data infile 'workdone.csv' into invoices
(workdone);'

The invoices table was filled in a certain order (by invoice number)
and the workdone.csv was exported in the same order, so each invoice
row should get its correct text.

Dumping Data To Easily Import Into MS Access
I have a db that I need to dump into a format that can be easily read my MS
Access. I tried the dump with regular PHPAdmin. Then I used the dump to
run a query in MS Access.

Errors occurred because MySQL inserts a backslash, "", in front of an
apostophe that user enters in a text field and MS Access doesn't know how to
interpret that.

Any ideas for easily getting whatever kind of data from MySQL to MS Access?

Import Database Overwrite And Data Elimination
When I imported files from one mysql database to another,I got no error messages, so the import was successful, but it also eliminated the information I had in the database into which I was importing. I thought the information would just be added to the information that was already existing. Any ideas of what could have happened?

Import Microsoft Access Data To MYSQL
I am receiving data in Microsoft Access MDB files. Is there a way to import some tables into MYSQL?

Import Minicom Data Into Mysql Database
I have mysql 5 running on fedora core 5, and I have data input through the minicom. I am trying to establish a connection between the minicom and database.

Dumping Data To Easily Import Into MS Access
I have a db that I need to dump into a format that can be easily read my MS
Access. I tried the dump with regular PHPAdmin. Then I used the dump to
run a query in MS Access.

Errors occurred because MySQL inserts a backslash, "", in front of an
apostophe that user enters in a text field and MS Access doesn't know how to
interpret that.

Any ideas for easily getting whatever kind of data from MySQL to MS Access?

Import Data Form Txt Or Cvs File Format
I have a fully installed version of MySql Server 5.0 including MySql Administration, MIGRATION Tool, Query Browser and System Tray Monitor.

I have lots of Data stored in a txt File. I do not want to type them all in. How do I import Data from a txt or cvs File format? They are standardizes.

Import Data From Text File Mysql
Im going to write a script in linux that updates my mysql database. How can i write a sql statemtn that updates my mysql table from a text file located on my machine?
lil confused bout the path of the txt file?

Most Efficient Way To Import Large Data Dump From Phpmyadmin?
I have a large data dump (export) from phpmyadmin my client just gave me - 200k - .

What's the most efficient way to import that into a new database? The new db has not defined tables since that is part of the phpmyadmin export.



Import Additional Field Data To Existing Table
I've got my data all set-up in a mysql table and all functioning well.

We have decided that we need some additional bits of data for each record and we have that data in a csv file. We've created the fields in the mysql table.

In the csv file, I have the userid (to match that in the current sql table) and the additional data with the column names in the csv file matching exactly the new fields in the sql table.

The additional fields in the original sql table are empty, so we can just simply write-over these fields with the data from the csv file.

But...we are having problems with the import using the MySql administration tool on our server.

If I select a csv file upload, I get a number of fields is not same error
If I use csv load data upload, it just overwrites the first few lines of current data and doesn't put the new data in the correct fields.

Can anybody help, please? If csv load data is the correct format to use, what do I put in the import tool for these variables (given that I have a standard csv file that has been created using excel)

Replace table data with file (yes/no default is no)
Ignore duplicate rows (yes/no - default is no)
Fields terminated by(default is
Fields enclosed by(default is ")
Fields escaped by(default is )
Lines terminated by(default is auto)
Column names (default is blank)
Use LOCAL keyword (yes/no - default is yes)



LOAD DATA INFILE Command To Import A Text File
I am using the LOAD DATA INFILE command to import a text file into
mysql.

However, there is much more text in the file than needed in my tables.
How can I make a selection from the text line. For example position 5 -
10 in field A, position 20-23 in field B, etc ...

Log Into MySQL Via Shell?
i can't figure out how to log into mysql via the shell. I am using Microsoft Windows 2000 SP4, so I would guess that I have to use the CMD... but I can't figure it out. I have the 'root' user setup and a password set on it... and i know how to control my databases and create tables and modify them and everything in PHP... but i want to know how in the shell so I don't have to create a new php page and execute it every time.

Shell And Mysql
I am trying to run a mysql batch script through the shell. The one
problem though is that the error messages out of my script dont go to
the redirect i.e., if I run

mysql<test.sql>test.log

the error messages do no print into test.log, but to the command line.
I would like to capture the errors into this log file as well. Any
ideas?

Shell And Sql Dump
Does anyone know where I can find information on how to setup my shell in
unix/linux to allow me to restore a database from an sql dump...
I have a database on 83200.mysql.com (example) that I have a file mysql.sql
(also just an example).
The file was produced using an sqldump command from a web interface...
How can I configure a connection if I am not on 83200.mysql.com so that I
can import the data into a database with a name of database_wordpress


Copyright © 2005-08 www.BigResource.com, All rights reserved