473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Load Data InFile fails

I have three users with access to my test MySQL databases, root plus two
others. The following PHP code only works when the user is root. Otherwise
it fails.

$File = addslashes(getcwd() . "\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die("Failed to load data");

Both users were created by root from a cmd prompt:

grant all on * to user@localhost identified by 'mypw' with grant options;

What is wrong so that the created users can execute the above code?

Thanks.

Bruce

Aug 2 '05 #1
4 2030
On Mon, 01 Aug 2005 21:38:41 -0400, Bruce A. Julseth decided we needed to
hear:
I have three users with access to my test MySQL databases, root plus two
others. The following PHP code only works when the user is root. Otherwise
it fails.

$File = addslashes(getcwd() . "\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die("Failed to load data");

Both users were created by root from a cmd prompt:

grant all on * to user@localhost identified by 'mypw' with grant options;

What is wrong so that the created users can execute the above code?

Thanks.

Bruce


Which db was current when you did the grant? If it was the mysql db,
then you probably just granted access to that rather than the ones
you intended to.
AFAIK (hopefully someone corrects if I'm wrong) a * on its own grants
only to the current db. You should change it to *.* if you want to grant
to all dbs, or use dbname.* for a specific db.
As an aside your privs are very broad here - I guess for test it doesn't
matter, but careful when you move to production.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Aug 2 '05 #2

"Dave" <da**@REMOVEbundook.com> wrote in message
news:pa****************************@REMOVEbundook. com...
On Mon, 01 Aug 2005 21:38:41 -0400, Bruce A. Julseth decided we needed to
hear:
I have three users with access to my test MySQL databases, root plus two
others. The following PHP code only works when the user is root.
Otherwise
it fails.

$File = addslashes(getcwd() . "\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die("Failed to load data");

Both users were created by root from a cmd prompt:

grant all on * to user@localhost identified by 'mypw' with grant options;

What is wrong so that the created users can execute the above code?

Thanks.

Bruce


Which db was current when you did the grant? If it was the mysql db,
then you probably just granted access to that rather than the ones
you intended to.
AFAIK (hopefully someone corrects if I'm wrong) a * on its own grants
only to the current db. You should change it to *.* if you want to grant
to all dbs, or use dbname.* for a specific db.
As an aside your privs are very broad here - I guess for test it doesn't
matter, but careful when you move to production.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)


Okay. I'll try to grant with *.*. I'll also experiment with "Use"ing
different databases before root issues the grant. Thanks.

Question: What are "privs "? I don't understand your statement "As an aside
your privs are very broad here - I guess for test it doesn't matter, but
careful when you move to production." I'd appreciate if you could expand on
your comment. Thanks..

Bruce
Aug 2 '05 #3
On Mon, 01 Aug 2005 23:32:29 -0400, Bruce A. Julseth decided we needed to
hear:
<snip>
Okay. I'll try to grant with *.*. I'll also experiment with "Use"ing
different databases before root issues the grant. Thanks.
hopefully that does the trick
Question: What are "privs "? I don't understand your statement "As an aside
your privs are very broad here - I guess for test it doesn't matter, but
careful when you move to production." I'd appreciate if you could expand on
your comment. Thanks..

Bruce


privs = privileges.

You are doing a grant all which grants every single privilege to
the user - plus you add the grant option which allows the user to
give those privs to other users.
Its (generally speaking) a bad practice to do this particularly
if the database is available directly over a network.
A better way is to grant to the user only those privs required
to perform the required task e.g. a user may only need to do
select and update (not delete, insert etc) so granting just those
two minimises risk should the worst happen and a malicious person
gets hold of the user/pass.

HTH

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Aug 2 '05 #4

"Dave" <da**@REMOVEbundook.com> wrote in message
news:pa****************************@REMOVEbundook. com...
On Mon, 01 Aug 2005 21:38:41 -0400, Bruce A. Julseth decided we needed to
hear:
I have three users with access to my test MySQL databases, root plus two
others. The following PHP code only works when the user is root.
Otherwise
it fails.

$File = addslashes(getcwd() . "\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die("Failed to load data");

Both users were created by root from a cmd prompt:

grant all on * to user@localhost identified by 'mypw' with grant options;

What is wrong so that the created users can execute the above code?

Thanks.

Bruce


Which db was current when you did the grant? If it was the mysql db,
then you probably just granted access to that rather than the ones
you intended to.
AFAIK (hopefully someone corrects if I'm wrong) a * on its own grants
only to the current db. You should change it to *.* if you want to grant
to all dbs, or use dbname.* for a specific db.
As an aside your privs are very broad here - I guess for test it doesn't
matter, but careful when you move to production.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)


Dave:

*.* in the grant seems to have fixed the problem. Thanks...

Bruce
Aug 2 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Bruce A. Julseth | last post by:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)" $File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\"...
3
by: hall | last post by:
I have a problem with my design of a templatized class. I'm trying to figure out how to load and save the data inside it, but can't. My class looks like this ------------------------------------...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
0
by: Juan Cabanela | last post by:
I am a relatively new user to MySQL running version 4.0.17 on MacOS X 10.3.3 (this is the "current version" installed by the Fink package manager). I login to mysql as root mysql -u root -p ...
1
by: Jami Bradley | last post by:
HI all, For the past several months we have been using LOAD DATA LOCAL INFILE to bulk load tables within Perl modules. Recently, someone thought it would be a good idea to upgrade the Solaris...
1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
4
by: CPD | last post by:
From PHP, doing a DROP TABLE and a CREATE TABLE is successful, but doing a LOAD FILE keeps failing, with the error "Access denied for user 'db_user'@'localhost' (using password: YES)". The...
0
by: lanesbalik | last post by:
hi all, right now i'm trying to migrate from db2 running under linux to mysql v5.1. i manage to export out the db2 structure & data into a del (ascii) file. but when i try to load the data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.