I try to import file menu.csv file to phpMyAdmin MySQL database this give me error message "#2 - File 'C:/Users/admin/Desktop/menu.csv' not found (Errcode: 2)"
I have tried used LOAD DATA LOCAL INFILE 'C:\Users\admin\Desktop\menu.csv' and 'C:\Users\admin\Desktop\menu.csv' none of them work. I also remove "LOCAL" keyword, still does not work. Can anyone please help
LOAD DATA LOCAL INFILE 'C:/Users/admin/Desktop/menu.csv'
INTO TABLE `Items`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES (
`items_items` , `price` , `section_id` , `items_description`
)
Try to put the file in this path 'C:\ProgramData\MySQL\MySQL Server 5.6\data' or the path for which ever mysql version you have. The Mysql server has permission to access the data in that path and should therefore be allowed to load the data in the file.
Related
I am working on a mysql (8) db which is too big for the 2TB linux partition size so I have moved the mysql instance onto a 16TB nvme raid under windows 10. All my other code is running on Debian 10 on a virtualbox instance and I have mapped a perm drive between the Debian VM and the nvme raid array.
I can open the database from debian and read and write as normal, so the odbc connector is working fine.
The issue here is the fact I am loading very large json log files into one table and doing it a row at a time was taking hours, so I opted to create a csv file for each log file and use LOAD DATA INFILE as part of the SQL statement.
Trouble is, when I execute the sql statement I get the 'file not found' issue, even though, looking at debug code, the file path is correct and it actually exists.
An excert from my python 3 code is:
p = f"/media/sf_unpack/{filename}"
try:
with open(p, 'r', buffering=1024 * 1024) as csvfile:
print(csvfile.read())
SQL = f"LOAD DATA INFILE '{p}' INTO TABLE xxx fields terminated by ',' LINES TERMINATED BY '\n' (field,field,.....etc) ;"
try:
mycursor.execute(SQL)
connection_object.commit()
except Exception as ex:
displayerror(ex)
This code will open the file correctly and show a value for p of /media/sf_unpack/filename.csv (which is correct).
When we get to the mycusror.execute(SQL) is raises an exception and says the directory or filename cannot be found. Interestingly, and I am sure this is the issue, the dubugger tells me the file that cannot be found is a windows version D:\media/sf_unpack/filename.csv - which looks as if it has something to do with the virtualbox mapping.
i.e. p =
I have tried to use the Path method from pathlib i.e p = Path(f"D:\mysql\unpack\{filename}" but that makes no difference.
I know I am doing something stupid but I am not sure what it is.
Any help would be gratefully recieved
I have tried many different possible solutions to resolve this issue but none seem to be fixing it for me.
I've tried solutions from other articles on here but none seem to be working
I am running MySQL 8.0 (LOAD DATA LOCAL INFILE is not supported in this version)
Im trying to load data from a csv file into my tables by means of LOAD DATA INFILE. When I run the script, I receive this error:
Error Code: 1290. The MySQL server is running with the
--secure-file-priv option so it cannot execute this statement
My code:
LOAD DATA INFILE 'customer.csv'
INTO TABLE customer
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
I have tried the following
In the '' put the full directory of the file in different formats, including trying both / and \
Remove the Secure-File-Priv from the config file
Changed the directory to the folder on my Desktop
Left the directory empty (Secure-File-Priv = "" {Also tried removing the ""})
I checked the directory by running the query and it says it is where I have it set to on my Desktop
Is there anything else that I could try to load data into my tables or to get the Secure File Priv block removed?
Update
This is the code with the error when the secure-file-priv is left empty:
LOAD DATA INFILE 'C:/users/user/desktop/college/advanced db/uploads/customer.csv'
INTO TABLE customer
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
Error Code: 29. File 'C:\users\carl\desktop\college\advanced
db\uploads\customer.csv' not found (OS errno 13 - Permission denied)
Assuming that you are using Windows 7 or more:
Search "services" in the windows research table (left-down of the screen)
Search the Mysql service in the table and shut down it
Open the my.ini file (i assume "C:\ProgramData\MySQL\my.ini")
Search for Secure-File-Priv and assign "".
Restart the process via "services" or Mysql workbench
Put the .csv file into the directory of the database where exists the table (in this case "customer"), this is the possible path: C:\ProgramData\MySQL\MySQL Server 8.0\Data\.
Execute the query
I am not able to load data from .csv file to MySQL database using shell script, I am using this command in Linux to import data:
mysql -utest -ptest123 --local_infile -e "use testing; LOAD DATA LOCAL INFILE '20160821-105501.cap.csv' INTO TABLE DataPackets FIELDS TERMINATED BY ',' ENCLOSED BY '"' IGNORE 1 LINES;"
But I always get stuck getting this sign ">"
I want to use the above command in shell script to automate the process.
You can use in shell as follow, I haven't tried but it may work for you..
mysql -utest -ptest123 --local_infile << END
use testing; LOAD DATA LOCAL INFILE '20160821-105501.cap.csv' INTO TABLE DataPackets FIELDS TERMINATED BY ',' ENCLOSED BY '"' IGNORE 1 LINES;
END
Hope it helps!
I ran the following command in the MySQL command line client, but I cannot find the outfile:
SELECT my_fieldname INTO OUTFILE 'D:\mypath\my_filename.txt'
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\n'
FROM my_tablename;
The command line prints out the following confirmation that the command ran properly:
Query OK, 9889 rows affected (0.02 sec)
But the file is not visible in D:\mypath\my_filename.txt and a search for my_filename.txt in the searchbox in the windows start menu does not produce any results.
This is being run on an instance of MySQL on my local development machine running Windows 7.
Where can I find the outfile? Or how can I change my command so that the outfile is actually created?
You need to escape backslashes in strings:
SELECT my_fieldname INTO OUTFILE 'D:\\mypath\\my_filename.txt'
or switch to forward slashes:
SELECT my_fieldname INTO OUTFILE 'D:/mypath/my_filename.txt'
Also, make sure that the MySQL server process is allowed to write into D:\mypath.
I would like to load a data file into MySQL using the following command:
LOAD DATA LOCAL INFILE '/Users/David/Desktop/popularity20110511/test_data' INTO TABLE test_table
The above command gives me the following error:
#7890 - Can't find file '/Users/David/Desktop/popularity20110511/test_data'.
I've also tried:
LOAD DATA INFILE '/Users/David/Desktop/popularity20110511/test_data' INTO TABLE test_table
I also gives me an error:
#13 - Can't get stat of '/Users/David/Desktop/popularity20110511/test_data' (Errcode: 13)
I've repeatedly checked the file path and name and I've also made sure the file privilege is set to Read & Write for everyone.
I am using a Mac and phpMyAdmin.
Any suggestions on what the problem may be?
I had the same problem using MacOs and tried to change permissions, etc, but I realized you have to use the same directory structure you have using in the Terminal Application. Example: if you have (localhost/myproject/myfile.csv) try using
(Applications/XAMPP/htdocs/myproject/myfile.csv).
LOAD DATA LOCAL INFILE '/Applications/XAMPP/htdocs/myproject/myfile.csv'
INTO TABLE `mytable`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\r';
I'm not too sure what the problem is but I made it work by moving the file to /tmp/test_data and used LOAD DATA INFILE...
I have had the same issue, trying to import an SQL file that uses LOAD DATA LOCAL INFILE... to import a CSV file in phpMyAdmin and got the same error message:
#7890 - Can't find file 'myfile.csv'
The solution I found was to put the file in the same folder as phpMyAdmin.
I was having the same problem
'C:/Program Files/DatabaseTableHolders/Menu.csv'
7890 - Can't find file '
The first thing I did was move the files to the "Program File" directory
It still wouldn't work
Then I changed the path address from
'C:/Program Files/DatabaseTableHolders/Menu.csv'
to
'C:\Program Files\DatabaseTableHolders\Menu.csv'
THIS WORKS!!!
For me its something to do with the path structure.
By the way I'm using Eclipse and phpMyAdmin on WAMP (windows operating system). I hope this helps.
Yes, I meet the same error.
My situation:
XAMPP + MAC OS 10.9
load data local infile '/Applications/XAMPP/xamppfiles/htdocs/jsonSQL.txt' into table `ttlegs` fields terminated by ',' lines terminated by '\n'
and this works when I put jsonSQL.txt to htdocs.
It is best if you put that text file in 'xammp /phpMyAdmin ' directory ( I assume you work on xammp) That's it. then LOAD DATA LOCAL INFILE will work. Happy Coding