How would I do the following command, with a local file, on a remote database (different machine) ?
$MYSQL_PATH/mysql -u root -h remote.net files -e " LOAD DATA INFILE '$1' INTO TABLE $TABLE_NAME FIELDS TERMINATED BY ',' (size, @d2, @d3, @d4, @d5, path)
The problem seems to be that the INFILE at /tmp/infile.txt
is not being recognized remotely. What would be the correct way to accomplish the above?
The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. If the LOCAL keyword is specified, the file is read from the client host. If LOCAL is not specified, the file must be located on the server. ( LOCAL is available in MySQL 3.22.
In contrast, when you execute the LOAD DATA LOCAL INFILE statement, the client attempts to read the input file from its file system, and it sends the contents of the input file to the MariaDB Server. This allows you to load files from the client's local file system into the database.
To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option. For the mysqlimport client, local data loading is not used by default. To disable or enable it explicitly, use the --local=0 or --local[=1] option.
To cause the server to permit access, set the local_infile variable with SET GLOBAL local_infile = 1; or check it with SHOW GLOBAL VARIABLES LIKE 'local_infile'; . Alternatively, edit mysql's config to include local_infile=1 .
LOAD DATA INFILE
loads a file on machine the MySQL server is running on.
Use LOAD DATA LOCAL INFILE
to load a file located on your client machine.
Don't forget to include --local-infile=1
when doing this:
$MYSQL_PATH/mysql -u root -h remote.net files --local-infile=1 -e " LOAD DATA LOCAL INFILE...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With