Reputation: 40912
Ok, I'm completely stumped here. I have setup an AWS RDS (free-tier) and tested the connection via mac os x terminal and I can connect perfectly fine.
I can also issue a connection statement with php (which seems to work) like this:
$this -> _mysqli = new mysqli( );
$this -> _mysqli -> init( );
$this -> _mysqli -> options(MYSQLI_OPT_LOCAL_INFILE, true);
$this -> _mysqli -> real_connect($host, $username, $password, $db, $port);
print_r( $this -> _mysqli );
/*print_r returns*/
mysqli Object (
[affected_rows] => 0
[client_info] => 5.5.33
[client_version] => 50533
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[error_list] => Array ( )
[field_count] => 0
[host_info] => sadmicrowave-dev.*****.*****-****.rds.amazonaws.com via TCP/IP
[info] =>
[insert_id] => 0
[server_info] => 5.6.13
[server_version] => 50613
[stat] => Uptime: 26448 Threads: 3 Questions: 27070 Slow queries: 0 Opens: 1962 Flush tables: 1 Open tables: 98 Queries per second avg: 1.023
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 122
[warning_count] => 0 )
Which seems to indicate to me that the connection succeeded; right? After that long-winded introduction of my setup, here comes my problem. Further down in my class I have a method to issue a query; it looks like this:
$q = mysqli_query(
$this -> _mysqli,
"LOAD DATA INFILE '$FILE'
IGNORE INTO TABLE `php-challenge-apr-2014`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES"
);
But this query returns the following error (despite the fact that I am working in the same class instance which means $this -> _mysqli
was already set in the connect statement above)
Access denied for user 'sadmicrowave'@'%' (using password: YES)]"}
What the F is going on?
Upvotes: 1
Views: 248
Reputation: 40912
This is SO dumb of me but I figured out my problem and it was that I forgot the local
keyword in the LOAD DATA
query. Without the local
keyword the MySQL server thinks I am trying to access a file on the server rather than on my localhost. Of course, in this case Amazon has probably locked this functionality down on their RDS instances for a reason; hence the Access Denied
issue.
Upvotes: 1