0

Question: How can we avoid errors of the following type with mysqlimport when the data file is in the current directory?

mysqlimport: Error: 13, Can't get stat of '/var/lib/mysql/«dbname»/«tablename».txt' (OS errno 2 - No such file or directory), when using table: «tablename»

We are using MySQL version 8.0.28.


Background:

Our issue started with LOAD DATA INFILE giving the following error:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

This issue was resolved by following the tip from https://computingforgeeks.com/how-to-solve-mysql-server-is-running-with-the-secure-file-priv-error/

Basically we edited the MySQL options file to set secure‐file‐priv = "".
Additionally we ensured that the owner and group of the file is set to mysql.

With these changes LOAD DATA INFILE is working like a charm. However, these changes have had no impact on mysqlimport.

mysqlimport gives the following error:

mysqlimport: Error: 13, Can't get stat of '/var/lib/mysql/«dbname»/«tablename».txt' (OS errno 2 - No such file or directory), when using table: «tablename»

3
  • Check if OS account used for mysqlimport execution have privileges in the filesystem for to access this file.
    – Akina
    Mar 17, 2022 at 20:12
  • @Akina the file is in /tmp directory and has 777 permission.
    – Sandeep
    Mar 17, 2022 at 20:19
  • Nevertheless mysqlimport cannot access this file. This is an issue in OS/filesystem permissions, not mysql/mariadb server problem.
    – Akina
    Mar 17, 2022 at 20:52

1 Answer 1

0

We were able to fix the problem by first enabling LOCAL capability for LOAD DATA

mysql> SET GLOBAL local_infile = TRUE;

After that we started invoking mysqlimport with --local option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.