LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2013, 07:22 AM   #16
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,655
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075

Quote:
Originally Posted by jonaskellens View Post
To grant "file" to a user other than root seems very dangerous...

I can't seem to find an alternative to import a csv-file into MySQL.
really? how about the root mysql-user?

I have Never used the file perm, nor have I Ever assigned it to anyone, nor never needed to for an import.
mysql -u <mysql_privileged_user> -p <db> < file.sql
 
Old 05-14-2013, 07:49 AM   #17
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,655
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
http://www.linuxquestions.org/questi...pt-4175461780/
 
Old 05-14-2013, 08:36 AM   #18
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by Habitual View Post
mysql -u <mysql_privileged_user> -p <db> < file.sql
This is no alternative to import a csv-file. Like I said earlier I have no sql-file but a csv-file.
 
Old 05-14-2013, 08:43 AM   #19
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by chrism01 View Post
bash is interpreted, I believe php is not, so php should be faster & less resources.
Then I will use php and my problem of importing csv-data into external MySQL-database will also be solved I guess.
 
Old 05-14-2013, 08:56 AM   #20
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,655
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
try http://dev.mysql.com/doc/refman/5.0/...ort.html#c5680

<IMO>I am not certain that "GRANT FILE" is what you really need to get this job done.</IMO>

typically, I'd load data as root into a specific mysql_db, this way I only have to worry about what I do to the db, NOT worry about THE USER
trashing stuff.
the .csv may need some "massaging", or manipulation.

See also:
http://stackoverflow.com/questions/6...a-command-line
http://kurinchilamp.kurinchilion.com...mand-line.html
and
http://alvinalexander.com/blog/post/...database-table

Good luck.
 
Old 05-14-2013, 09:05 AM   #21
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by Habitual View Post
typically, I'd load data as root into a specific mysql_db
I can not reveal root login information inside the bash script.
 
Old 05-14-2013, 10:03 AM   #22
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,655
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
Quote:
Originally Posted by jonaskellens View Post
I can not reveal root login information inside the bash script.
Who said anything about revealing any passwords?
http://kurinchilamp.kurinchilion.com...mand-line.html

If you want to be spoon-fed, I charge $1000.00 per hour USD.

Easy answer: and the sanest, Create a csv-only user.
Code:
mysql -u root -p grant all privileges on dbname.* to csv_import@localhost ‘IDENTIFIED BY ‘n4Tur3aL’; flush privileges;"
then use mysql -u csv_import -p n4Tur3aL and work the import using those credentials.

Last edited by Habitual; 05-14-2013 at 10:13 AM.
 
Old 05-14-2013, 10:15 AM   #23
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
In your link passwords are revealed. This is not useful. Even if you charge $50.00 I would not recommend you.

Meanwhile I found another solution combining php and bash, which gives me the best of both worlds.
 
Old 05-14-2013, 10:16 AM   #24
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,094

Rep: Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515
Hi. Why are you trying to import the rest of the file into a sql database? I dont like the idea. I make a shell script, and make a sql file, then import the sql file with the shell script.

Anyway... try this in your script.


Code:
#!/bin/bash -l

mysql -u MyUser -pMyPassword -h ip_databaseserver -D My-DB < some_file.sql
 
Old 05-14-2013, 10:29 AM   #25
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,655
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
Quote:
Originally Posted by jonaskellens View Post
In your link passwords are revealed.
Big Fargin' Deal. Change it?
Quote:
This is not useful.
Again with the "spoon-feed me" response.
Quote:
Even if you charge $50.00 I would not recommend you.
I'm not sure you could count it.

Quote:
Meanwhile I found another solution combining php and bash, which gives me the best of both worlds.
You are all over the map on this "solution".

Good luck.
 
Old 05-14-2013, 10:43 AM   #26
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by szboardstretcher View Post
Hi. Why are you trying to import the rest of the file into a sql database? I dont like the idea. I make a shell script, and make a sql file, then import the sql file with the shell script.
We have software that produces csv-files.

What I wanted is a bash script that puts the content of these csv-files into a remote MySQL-database.

But I was getting the error in my original post, which seemed to be related to the lack of the "FILE"-permission of the database user.

Adding the "FILE"-permission to the user seemed unsafe.

So that is where I stranded with the bash-script.

Found another way to implement using php and bash.

Thanks.
 
Old 05-14-2013, 10:49 AM   #27
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,094

Rep: Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515
Quote:
Originally Posted by jonaskellens View Post
Found another way to implement using php and bash.
Good to hear. Mind sharing the php/bash way with us, so this thread can be useful to someone in the future?
 
Old 05-14-2013, 10:18 PM   #28
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Merged the two VERY closely related threads.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Why does this work from the bash command line and then fails in a bash script? Rupadhya Linux - Newbie 5 09-26-2012 01:05 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM
Can MySQL log on via SSH/bash? mysql:x:27:101:MySQL Server:/var/lib/mysql:/bin/bash Ujjain Linux - Newbie 2 04-24-2009 03:21 PM
Bash script run via cron not executing MYSQL command mackstar Linux - Server 4 04-23-2009 06:01 AM
Is 'nice' inherited to child processes? e.g. bash script/php script that calls MySQL SirTristan Linux - Newbie 1 12-04-2008 01:57 AM


All times are GMT -5. The time now is 08:38 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration