Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I enable XAMPP to "SELECT ... INTO OUTFILE   'myfile.txt' ;"

Posted on 2014-12-09
7
Medium Priority
?
381 Views
Last Modified: 2014-12-15
HI,

I hope this makes sense, coming up on 24 hours awake now, so please bear with me.


Of course as mysql's root I can run the query and it puts the file into
XAMPP/xamppfiles/temp   just fine.


Bits of info I know and understand:

In /Applications/XAMPP/xamppfiles/etc/httpd.conf
I see:
  User daemon
  Group daemon

Also:
<Directory />
    AllowOverride none
    Require all denied
</Directory>

How would I (should I) configure another directory entry with allow into it?
<Directory /whatpathdoIstartwithhere>
   AllowOverride ????
  Require ?? ?????
</Directory>

What else is there?

Thanks from Seattle.
0
Comment
Question by:Ralph
[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
  • 4
  • 3
7 Comments
 
LVL 35

Assisted Solution

by:ste5an
ste5an earned 2000 total points
ID: 40488679
The Apache directory settings do not control what you are allowed to do in MySQL. But when it's about to read that file, then you may use

<Directory /XAMPP/xamppfiles/temp >
 </Directory>

The permissions depend on your needs. See <Directory> Directive.
0
 

Author Comment

by:Ralph
ID: 40490480
Thank you!
I'm working on those directives now.

I have yet to find a clear definition of them, but I'll keep looking.
All I want is to be able to SELECT... OUTPUT TO DATAFILE,
and NO http:// access.
0
 
LVL 35

Expert Comment

by:ste5an
ID: 40490740
Then you don't need to fiddle with your Apache config.

Just execute your SELECT statement.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:Ralph
ID: 40495489
The select works, but no data is output when XAMPP runs it.

I get a result file when I run it as ralph@localhost.
ralph has SELECT, INSERT, UPDATE, DELETE, FILE Global privs,
  and NONE set for database 'dbviablitz'.
The file shows up in /Applications/XAMPP/xamppfiles/var/mysql.

The PHP script generates this command:

SELECT 'Fri Dec 12 4:50:46 CET 2014', 'DnD', 'dbviablitz', '', '' INTO OUTFILE 'thefilename.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\n';

When run by PHP it generates no output file.
When I run it at the mysql prompt I do.

===================================
Some entries in my http.conf file follow.

But first, could it be WHO the server is running as?
drwxrwxr-x   11 root    admin     374 Dec 11 19:50 var
drwxrwxr-x  17 _mysql  _mysql    578 Dec 11 20:19 mysql

----------------------
ServerRoot "/Applications/XAMPP/xamppfiles"
----------------------
<IfDefine JUSTTOMAKEAPXSHAPPY>
LoadModule php4_module        modules/libphp4.so
LoadModule php5_module        modules/libphp5.so
</IfDefine>
----------------------
<IfModule unixd_module>   # Which I have
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
</IfModule>
----------------------
ServerName localhost
----------------------
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
   
    Options Indexes FollowSymLinks ExecCGI Includes

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    # since XAMPP 1.4:
   
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>
----------------------

=====================================
I can see nothing of interest in .../xamppfiles/log
or in any logs c/o the Console App.

----------------------
What am I missing?
Surely daemon mysql has FILE privilege.  Shouldn't it?
0
 

Author Comment

by:Ralph
ID: 40498573
The select works, but no data is output when XAMPP runs it.  I get a result file when I run it as or myself.
0
 
LVL 35

Accepted Solution

by:
ste5an earned 2000 total points
ID: 40499879
Then XAMPP mysqld account has not the appropriate permissions to write at this path.
0
 

Author Closing Comment

by:Ralph
ID: 40501788
Turns out without giving a path for the OUTPUT FILE it goes into xamppfiles/var/mysql
which is a protected DIR from the world.
I used an indirect path to locate it into xamppfiles/temp, where my cron job picked it up and removed it from there.
NOT the most secure, but for now it will do.  I'll get with godaddy to find out what they recommend.

Thanks all.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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