1

UPD: The question is different from MySQL: Enable LOAD DATA LOCAL INFILE

That question is related to LOCAL run and nothing to do with travis build, locally, using that options everything works like a charm, no problem with it, but running in travis, also requesting mysql not with mysql client, but programmaticaly - so i can't set any client option, this makes my case different.

i am trying to set up travis build - and running into error

MySQLdb.OperationalError: (2068, 'LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.')

I tried local_infile option, as i do on my local system:

mysql -u root -h localhost -e 'SET GLOBAL local_infile=1'

(I tried this option at before install section, at install section)

But still it doesn't help.

I am completly stuck without ideas where to move further. Appreciate any help.

My travis config is following:

 language: python
os: linux
dist: jammy

services:
  - mysql

python:
  - "3.10.5"

env:
  - TESTENV=test

before_install:
  - mysql -u root -h localhost -e 'GRANT ALL PRIVILEGES ON *.* TO "travis"@"%"'
install:
  - pip3 install --upgrade pip
  - pip3 install --upgrade setuptools wheel
  - mysql -u root -h localhost -e 'SET GLOBAL local_infile=1'
  - pip3 install -r requirements.txt
  - if [[ "$TESTENV" != "docs" ]]; then pip3 install -r requirements-test.txt; fi
  - pip3 install -e .

script:
  - if [[ "$TESTENV" == "test" ]]; then coverage run -m pytest --server=mysql://travis@127.0.0.1:3306/ src/tests; fi
  - if [[ "$TESTENV" == "test" ]]; then coverage report -m; fi
user453575457
  • 464
  • 6
  • 21
  • You need to set `local-infile` both in the server (which you did with the SET GLOBAL command) and also in the client, with `mysql --local-infile ...`. See https://dev.mysql.com/doc/refman/8.0/en/load-data-local-security.html for documentation and examples. – Bill Karwin Apr 29 '23 at 18:06
  • @BillKarwin I don't have client, it is my application that works with mysql – user453575457 Apr 29 '23 at 18:14

1 Answers1

1

The MySQL DSN might accept local_infile=1 as an argument. Example:

coverage run -m pytest --server=mysql://travis@127.0.0.1:3306/?local_infile=1 src/tests

I can't confirm this, because the versions of coverage and pytest I have installed don't recognize the --server option. I can't find any documentation of that flag. So I don't know exactly what you're using.

Also the support for the local_infile option may depend on which database driver you're using, e.g. mysql.connector, pymysql, etc.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828