i would like to import csv file in mysql database.
my query would be like the following.
query = "LOAD DATA INFILE '"+filename+"' INTO TABLE testtable FIELDS TERMINATED BY ',' (text,price)";
But i got the following error while importing file.
java.sql.SQLException: Access denied for user 'root'#'%' (using password: YES)
for full source code you can see http://www.javalobby.org/java/forums/t53674.html.
Any Help is greatly appriciated.
Thanks.
the user you are using does not have the privileges to load data
you might also need to specify LOAD DATA LOCAL
make use user root allowed to access other than from localhost
as error shows, you should double check if user-password-host-db combination is correct. this is what the error tells you.
Make sure you are allowed to log into the database as root and you have the correct password in your connect string (caspian)
Connection conn = db.connect("jdbc:mysql://localhost:3306/test","root","caspian");
Related
When I try to export records using the below query, I am getting an error
SELECT ID, Name FROM Emp
INTO OUTFILE 'C:/temp/hash.csv'
FIELDS ENCLOSED BY '"'
TERMINATED BY ';'
ESCAPED BY '"'
LINES TERMINATED BY '\r\n';
Error:
SQL Error (1045): Access denied for user 'test'#'%' (using password: YES)
I am getting same error while running the below:
GRANT FILE ON *.* TO 'test';
SHOW VARIABLES LIKE "secure_file_priv";
secure_file_priv: /tmp/
I want to run a stored procedure to export the records through a .Net application. I am expecting the output file to be created on the windows computer. The MySQL instance is running on AWS.I think the "secure_file_priv" path is causing the issue. The same query is working in another MySQL instance that is running on windows server.
Thank you.
You need to out file the csv file to aws instance first, and then download it to your windows computer.
I have a table in a database myDatabase in Amazon RDS. Let it be myTable.
use myDatabase;
SELECT * from myTable INTO OUTFILE 'myFile.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"'LINES
TERMINATED BY '\n';
I get this error
Error Code: 1045. Access denied for user '<<UserName>>'#'%' (using password: YES)
I tried running this command
GRANT USAGE ON *.* TO '<<UserName>>'#'%' IDENTIFIED BY '<<password>>';
flush privileges;
0 row(s) affected, 1 warning(s): 1287 Using GRANT statement to modify existing user's
properties other than privileges is deprecated and will be removed in future release. Use
ALTER USER statement for this operation.
I get this warning.
And
I am not able to export the table into a .CSV file at all.
Any idea on how to solve it ? Any thoughts on the steps which might have gone wrong ?
Make sure your user has the FILE privilege.
FILE
Affects the following operations and server behaviors:
Enables reading and writing files on the server host using the LOAD DATA and SELECT ... INTO OUTFILE statements and the LOAD_FILE()
function. A user who has the FILE privilege can read any file on the
server host that is either world-readable or readable by the MySQL
server. (This implies the user can read any file in any database
directory, because the server can access any of those files.)
Enables creating new files in any directory where the MySQL server has write access. This includes the server's data directory containing
the files that implement the privilege tables.
manual entry
i have a simple shell script that is trying to connect to a database and is trying to load a text file into a database table through load infile statement inside a script and the script throws this error
ERROR 1045 (28000) at line 6: Access denied for user 'user'#'%' (using password: YES)
The script is
#!/bin/bash
#connect to the db
mysql -u bsm_admin -pbsmP1N1 -h ilcldbpbsm01 << EOFMYSQL
show databases;
use database;
show tables;
load data infile 'plugins.txt' into table jenkins fields terminated by ':' lines terminated by '\n';
EOFMYSQL
so the problem is other statememts work but the error comes at load data infile line.
i tried checking whether the user has write permissions to the database and i was able to create and insert data to the table through command line, so i am guessing it is not a permission issue.
Also i didnot create the user, it was already created.
This is because you don't have FILE privilege. Refer to mysql manual
The FILE privilege gives you permission to read and write files on the server host using the LOAD DATA INFILE and SELECT ... INTO OUTFILE statements and the LOAD_FILE() function.
I'm trying to use PHPmyadmin to import a CSV file to a mysql database, however I get a 1045 error. I get the following error:
#1045 - Access denied for user 'tipsandb_saadat'#'localhost' (using password: YES)
I know that this is a rather old question but I had the same issue with mySql 5.1.61.
What I tried to do was, from a MySql client, to run the following command:
LOAD DATA INFILE '/myProjectDir/theFile.csv'
INTO TABLE someTable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
I gathered information from various places, tried several options and figured out that all these points must be checked:
the user must have FILE privilege:
GRANT FILE ON *.* TO 'theUser'#'%' IDENTIFIED BY 'thePassword';
the file permissions must be set so that the world can read it (actually it shall be OK if the mysqld process is able to read it):
chmod o+r theFile.csv
the file must be located in the dedicated temporary directory that is defined in the my.cnf config file:
[mysqld]
tmpdir=/tmp/mysql
every item in the file path must have its permissions set in the same fashion as the file itself
You need the FILE privilege to use this command.
I am running into a permission error when trying to load data from a flat file database dump into a new table. I know that the schema of the file and my table is the same and I tried tweaking the permissions. What else should I try?
mysql> load data infile 'myfile.txt' into table mytable fields terminated by ',' enclosed by '"';
ERROR 1045 (28000): Access denied for user 'user'#'%'
grant all on mytable.* to 'user'#'%
Here's a thread on the MySQL forums that discusses exactly this.
Here's the answer, posted by Ken Tassell
Problem resolved using the command below:
grant file on *.* to kentest#localhost identified by 'kentest1';
You might have MySQL privileges on the destination table, but you also need the FILE privilege to execute LOAD DATA, and of course the MySQL Server process needs operating-system privileges to the data file too.