Error 2068 hy000 load data local infile file request rejected due to restrictions on access

Bash скрипт для загрузки CSV в таблицу MySQL удалённого сервера с использованием LOAD DATA LOCAL INFILE, решение ошибки ERROR 2068 (HY000)

Дано: требуется синхронизация данных между системами, входная информация раз в час поступает в виде файла в формате CSV через запрос к веб сервису, должна быть загружена в таблицу MySQL. Сервер MySQL не локальный. ОС Oracle Linux 7, MySQL 8

Что не работает

Неработающий скрипт:

#!/bin/bash
## переменные
DIR="/opt/syncdata"
SCRIPTNAME="statictable_import"
LOGFILE="$DIR/LOG/$SCRIPTNAME.log"
SCRIPTNAME="statictable_import"
DB="TEMPDB03"
DBTABLE="STATICTABLE"
CSVFILE="$DIR/CSV/STATICTABLE.CSV"
MYSQL="/usr/bin/mysql"
WGET="/usr/bin/wget"
## загрузка файла из веб-сервиса и сохранение его в каталог CSV
$WGET -O $CSVFILE https://USR0045:PASSWORD@restservice.local/pls/src_data/grafana/statictable
## подключение к MySQL и очищение таблицы
$MYSQL --database=$DB<<EOFMYSQL
TRUNCATE TABLE $DBTABLE;
EOFMYSQL
## загрузка данных из файла
$MYSQL --database=$DB<<EOFMYSQL
load data local infile '$CSVFILE' replace INTO TABLE $DBTABLE
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY 'n'
IGNORE 1 LINES
(ID,
TABLENAME,
NAME,
TIME,
VALUE01,
VALUE02,
VALUE03,
VALUE04,
VALUE05,
VALUE06,
VALUE07,
VALUE08
);
EOFMYSQL

Первая ошибка:

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.`

Запрещено. Это решается переменной сервера, проверяем её:

SHOW GLOBAL VARIABLES LIKE 'local_infile';
'local_infile','OFF'

Запрещаем запрещать и снова проверяем

SET GLOBAL local_infile = 'ON';
SHOW GLOBAL VARIABLES LIKE 'local_infile'
'local_infile','ON'

Выполняем скрипт, опять получаем ошибку:

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.`

Устанавливаем переменную в *.ini сервера и перезапускаем сервер

local_infile=ON

И опять не работает.

ERROR 2068 (HY000) at line 1: LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

Решение

Не уверен баг это или особенность, но помимо глобальной переменной сервера требуется опция в команде mysql: –local-infile=1

Работающий скрипт:

#!/bin/bash
## переменные
DIR="/opt/syncdata"
SCRIPTNAME="statictable_import"
LOGFILE="$DIR/LOG/$SCRIPTNAME.log"
SCRIPTNAME="statictable_import"
DB="TEMPDB03"
DBTABLE="STATICTABLE"
CSVFILE="$DIR/CSV/STATICTABLE.CSV"
MYSQL="/usr/bin/mysql"
WGET="/usr/bin/wget"
## загрузка файла и сохранение его в каталог CSV
$WGET -O $CSVFILE https://USR0045:PASSWORD@restservice.local/pls/f_data/grafana/statictable
## подключение к MySQL и очищение таблицы
$MYSQL --database=$DB<<EOFMYSQL
TRUNCATE TABLE $DBTABLE;
EOFMYSQL
## загрузка данных из файла
$MYSQL  --local-infile=1 --database=$DB<<EOFMYSQL
load data local infile '$CSVFILE' replace INTO TABLE $DBTABLE
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY 'n' 
IGNORE 1 LINES
(ID,
TABLENAME,
NAME,
TIME,
VALUE01,
VALUE02,
VALUE03,
VALUE04,
VALUE05,
VALUE06,
VALUE07,
VALUE08
);
EOFMYSQL

Хинт. Сервер удалённый, а в скрипте не используется логин, пароль и имя сервера MySQL. В ОС создан пользователь от имени которого выполняется синхронизация, в пространстве пользователя настроен CRONTAB со всеми задачами синхронизации, в файле ~/.my.cnf пользователя хранятся настройки подключения к MySQL.

cat ~/.my.cnf 
[client]
user=USER_TEMPDB03
password="PASSWORD"
host=mysql02-master.local

ОШИБКА 2068 (HY000): Запрос файла LOAD DATA LOCAL INFILE отклонен из-за ограничений на доступ

комментарий я пытаюсь ,

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.`

Он работал нормально, я скачал pymysql и соединитель mysql для скрипта python. Я удалил и проверил, все равно не работает. Версия и файл включены,

Эта проблема возникла при использовании MySql Workbench 8 или выше. Это исправило это для меня:

This restriction can be removed from MySQL Workbench 8.0 in the following way. Edit the connection, on the Connection tab, go to the ‘Advanced’ sub-tab, and in the ‘Others:’ box add the line ‘OPT_LOCAL_INFILE=1’.

This should allow a client using the Workbench to run LOAD DATA INFILE as usual.

для обходного пути при попытке подключиться к mysql сам по себе установите для local-infile значение 1 и выполните команду загрузки: mysql —local-infile=1 -h$MASTER_DB_HOST -u$MASTER_DB_USER -p$MASTER_DB_PASSWD -D$MASTER_DB_NAME

отредактируйте файл /etc/mysql/mysql.conf.d/mysqld.cnf и добавьте в конец следующую строку:

# безопасный_файл_priv=»»

запустите: mysql -u root -p и проверьте локальную переменную infile

Чтобы исправить эту ошибку (mysql 8):

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

добавьте следующую строку в файл конфигурации вашего сервера в разделе «клиент»:

Это исправит ошибку. Однако это предполагает, что вы уже установили следующее в разделе «mysqld»:

Установка обоих параметров в файле конфигурации позволит загружать данные из любого каталога.

Вот простой пример использования. Запустите в терминале mysql:

Для пользователей Mac, если вышеуказанные решения не работают (и я использую Mac OS Big Sur)

Подойдите к терминалу и введите

Затем добавьте это в файл

Сохраните и выйдите из окна. Теперь перейдите в терминал и перезапустите сервер mysql, используя

введите сервер mysql, используя

Теперь введите следующее в mysql

Это должно показать значение переменной как пустое. Теперь, если вы используете запрос

Это должно работать! также убедитесь, что вы установили следующую переменную в «ON», используя:

Обновлять

Для пользователя Windows — после установки mysql 8.0 указана безопасная файловая переменная, упомянутая выше.

Источник

I am a new MySQL user trying to follow the introductory tutorial from Oracle.

I was unable to load data into a table from a text file (this step of the tutorial).

/.my.cn as described here.

returns exactly the same error. That is, it doesn’t seem to matter what path I put there. It doesn’t even matter whether this is a real path to a real file.

After a few hours of mucking around, I was able to find one thing that worked: placing the files inside the folder containing the tables of my database:

(Dining is the name of the database.) Then loading the data works just fine.

Strangely enough, there quite literally does not seem to be any discussion of this error on the internet, aside from that one lonely comment linked above. There is a brief listing of the error code on the Oracle website, but I haven’t found so much as a github comment about this error code.

I am using Amazon RDS MySql for data storage. I am able to load data by specifying the column values, however, when I try to load the data from my local machine to MySql, it fails with Error: 2068.

Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

If i use Terminal to open a connection with MySql and execute the command there, it works ok.

But how to make it work in MySql Workbench.

It seems that there is a bug in MySQL Workbench for LOAD DATA LOCAL INFILE, check if the workaround in this link works for you:

The solution that worked for me is from the workarounds shared in the link: Workbench 8.0.12 no longer allows LOAD DATA LOCAL INFILE as shared by @Zacca.

Set the my.cnf file as the default configuration file in MySql Workbench. Click the Wrench icon next to Instance. Under configuration file, enter the path to my.cnf file: /etc/my.cnf.

Restart the MySQL server workbench.

Try the following statements in MySQL Workbench: SHOW VARIABLES LIKE «local_infile»; //Should be ON SHOW VARIABLES LIKE «secure_file_priv»; //Should have no values (not NULL but blank)

Using LOCAL keyword, loading is successful. However, without LOCAL keyword, I get access error.

Error Code: 1045. Access denied for user ‘admin’@’%’ (using password: YES)

After beating my head around this for an hour, I switched back to MySQL Workbench 6.3. Bliss.

Adding what worked for me here, I was able to find a working solution through the links @Zacca provided, but I had to dig through solutions that didn’t work, and I thought I’d repost here in case those links die at some point.

First, if I ran SHOW GLOBAL VARIABLES LIKE ‘local_infile’; I can see that INFILE is enabled. However, I was still getting «ERROR CODE 2068»

I was able to resolve this by editing the connection string in MySQL workbench by navigating to Home, then:

Edit Connection > Advanced > Copy OPT_LOCAL_INFILE=1 into Others box on a new line

Then restart the connection. After that, LOAD LOCAL INFILE runs without error.

Also, as a side note, before I found this solution, I found I could run the LOAD LOCAL INFILE command from R without issue, which helped me isolate the client as the issue, as opposed to a security/permissions related problem.

Источник

Response like that `Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.’ When I load the data from CSV

When I run the code below in MySQL5.0, I will have a response like:

Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

I already set the local infile to On, but still not working, do I need to still change any parameter?

1 Answer 1

OK, I found the solution finally, we need to go to the MySQL Command Line Client (My version is 5.7), and change all the in the path to / , like

In the workbench and cell will show us the different error, in the cell, the response is Error 1148, in the workbench is 2068.

Linked

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.1.11.43150

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

MySQL : Load data infile

I am getting error when using load data to insert the query .

This file is there in the location . But mysql throws the below error . ERROR 29 (HY000): File ‘/home/bharathi/out.txt’ not found (Errcode: 13)

Data Dir is pointing to root permissioned folder . I can’t change this variable because it’s readonly .

How can I do the load data infile operation ?

I tried changing file permissions , load data local infile . It wont work .

2 Answers 2

For security reasons, when reading text files located on the server, the files must either reside in the database directory or be readable by all. Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege. See Section 6.2.1, “Privileges Provided by MySQL”. For non- LOCAL load operations, if the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

You should therefore either:

Ensure that your MySQL user has the FILE privilege and, assuming that the secure_file_priv system variable is not set:

make the file readable by all; or

move the file into the database directory.

Or else, use the LOCAL keyword to have the file read by your client and transmitted to the server. However, note that:

LOCAL works only if your server and your client both have been configured to permit it. For example, if mysqld was started with —local-infile=0 , LOCAL does not work. See Section 6.1.6, “Security Issues with LOAD DATA LOCAL ”.

Источник

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access

comment I’m trying ,

ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.`

It was working fine, I downloaded pymysql and mysql connector for the python script. I uninstalled and checked still it is not working. The verion and infile is ON,

8 Answers 8

Using MySql Workbench 8 or above introduced this issue. This fixed it for me:

This restriction can be removed from MySQL Workbench 8.0 in the following way. Edit the connection, on the Connection tab, go to the ‘Advanced’ sub-tab, and in the ‘Others:’ box add the line ‘OPT_LOCAL_INFILE=1’.

This should allow a client using the Workbench to run LOAD DATA INFILE as usual.

for workaround when trying to connect to mysql in itself set local-infile to 1 and perform the load command: mysql —local-infile=1 -h$MASTER_DB_HOST -u$MASTER_DB_USER -p$MASTER_DB_PASSWD -D$MASTER_DB_NAME

  1. edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and add the following:
  1. Restart the service

    run: mysql -u root -p and check the local infile variable

    To Fix this error (mysql 8):

    ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

    add the following line into your server’s config file, under the «client» section:

    That will fix the error. However, this assumes you have already set the following under the «mysqld» section:

    Having both parameters set in your config file will allow loading data from any directory.

    Here’s a simple example of use. Run in the mysql terminal:

    For Mac users, if the above solutions don’t work (and I am using mac OS Big Sur)

    Go to the terminal and type

    Then add this to the file

    Save and exit the window. Now go to terminal and restart mysql server using

    enter mysql server using

    Now enter the following in mysql

    This should show the value of the variable as blank. Now if you use the query

    This should work! also make sure you have set the following variable to «ON» using:

    Update

    For windows user — having mysql 8.0 installed following is the secure file variable mentioned above

    on windows :
    for me after enabling local in both client and server and settings (in my.ini)

    For mac m1 users (Big Sur, Monterey, Ventura) :-

    • First System Preferences —> MySql «Stop MySql Server»

    For macOS «Ventura» will go at the bottom of System Settings for MySQL

    • Create etc/my.cnf file in /usr/local i.e ( /usr/local/etc/my.cnf )

    • Now edit the «my.cnf» file using TextEdit:-

    follow the images as shown

    Under connection —> Advanced —> Others (Edit it):-

    • Under System Preferences «Start MySql Server»

    • Always use it in your code in MySql Workbench for things to work

    If you like this method then please upvote this post

    ERROR 2068: LOAD DATA LOCAL INFILE file request rejected due to restrictions on access

    On Windows 11 64-bit operating system, x64-based processor, build 22621.963, Version 22H2 — MySQL installed using the web installer .MSI file as a developer configuration.

    Change my.ini from the default in C:ProgramDataMySQLMySQL Server 8.0

    In the [client] section add local_infile=ON

    The following code then works for me from MySQL Workbench connected to my local instance —

    Use this data by creating a .CSV file

    Copy the .CSV file to C:ProgramDataMySQLMySQL Server 8.0Datanorthwind

    This code works to load the shippers table —

    SELECT VERSION(); gives ‘8.0.31’

    Help > About Workbench gives «Version 8.0.31 build 2235049 CE 64 bits»

    Источник

Known issue: https://bugs.mysql.com/bug.php?id=91872

for workaround when trying to connect to mysql in itself set local-infile to 1 and perform the load command:
mysql —local-infile=1 -h$MASTER_DB_HOST -u$MASTER_DB_USER -p$MASTER_DB_PASSWD -D$MASTER_DB_NAME

Using MySql Workbench 8 or above introduced this issue. This fixed it for me:

This restriction can be removed from MySQL Workbench 8.0 in the
following way. Edit the connection, on the Connection tab, go to the
‘Advanced’ sub-tab, and in the ‘Others:’ box add the line
‘OPT_LOCAL_INFILE=1’.

This should allow a client using the Workbench to run LOAD DATA INFILE
as usual.

Quoted from this link:
https://bugs.mysql.com/bug.php?id=91872

For ubuntu:

  1. edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and add the following line at the end:

    # secure_file_priv=»»

  2. Restart the service

     systemctl stop mysql 
     systemctl start mysql
    
  3. run: mysql -u root -p and check the local infile variable

      mysql> show global variables like 'local_infile';
    
      +---------------+-------+ 
      | Variable_name | Value |
      +---------------+-------+
      | local_infile  | OFF   |
      +---------------+-------+
      1 row in set (0.00 sec)
    
  4.   mysql> set global local_infile=true;
    
      +---------------+-------+ 
      | Variable_name | Value |
      +---------------+-------+
      | local_infile  | ON    |
      +---------------+-------+
      1 row in set (0.00 sec)
    
  5.   mysql> exit
      Bye
    
  1. run

     mysql --local-infile=1 -u root -p
    
  2.   LOAD DATA INFILE '/var/lib/mysql-files/filename' INTO TABLE tablename;
    

Tags:

Mysql

Load

Related

# get all backup policy with retention times, including vmnames
RecoveryServicesResources
    | where type == 'microsoft.recoveryservices/vaults/backuppolicies'
    | extend xvaultName = case(type == 'microsoft.recoveryservices/vaults/backuppolicies', split(split(id, 'microsoft.recoveryservices/vaults/')[1],'/')[0],type == 'microsoft.recoveryservices/vaults/backuppolicies', split(split(id, 'microsoft.recoveryservices/vaults/')[1],'/')[0],'--')
    | extend datasourceType = case(type == 'microsoft.recoveryservices/vaults/backuppolicies', properties.backupManagementType,type == 'microsoft.dataprotection/backupVaults/backupPolicies',properties.datasourceTypes[0],'--')
    | extend policyID = id
    | extend dailyDurationType = replace('"','',replace(':','',replace('durationType','',replace('{','',tostring(split(properties.retentionPolicy.dailySchedule.retentionDuration,',')[0])))))
    | extend daylyLTR = replace('"','',replace(':','',replace('count','',replace('}','',tostring(split(properties.retentionPolicy.dailySchedule.retentionDuration,',')[1])))))
    | extend DailyBackup = strcat("Daily, retention Duration ", daylyLTR, " ", dailyDurationType)
    | extend weeklyDurationType = replace('"','',replace(':','',replace('durationType','',replace('{','',tostring(split(properties.retentionPolicy.weeklySchedule.retentionDuration,',')[0])))))
    | extend weeklyLTR = replace('"','',replace(':','',replace('count','',replace('}','',tostring(split(properties.retentionPolicy.weeklySchedule.retentionDuration,',')[1])))))
    | extend weeklyStartDate = split(tostring(properties.retentionPolicy.weeklySchedule.daysOfTheWeek),'"')[1]
    | extend WeeklyBackup = strcat("Every ", weeklyStartDate, ", retention Duration ", weeklyLTR, " ", weeklyDurationType)
    | extend monthlyDurationType = replace('"','',replace(':','',replace('durationType','',replace('{','',tostring(split(properties.retentionPolicy.monthlySchedule.retentionDuration,',')[0])))))
    | extend monthlyLTR = replace('"','',replace(':','',replace('count','',replace('}','',tostring(split(properties.retentionPolicy.monthlySchedule.retentionDuration,',')[1])))))
    | extend monthlyStartDayWeek =  split(tostring(properties.retentionPolicy.monthlySchedule.retentionScheduleWeekly.daysOfTheWeek),'"')[1]
    | extend monthlyStartWeekMonth =  split(tostring(properties.retentionPolicy.monthlySchedule.retentionScheduleWeekly.weeksOfTheMonth),'"')[1]
    | extend MonthlyBackup = strcat("Every ", monthlyStartDayWeek, " ", monthlyStartWeekMonth, " Week, retention Duration ", monthlyLTR, " " , monthlyDurationType)
    | extend yearDurationType = replace('"','',replace(':','',replace('durationType','',replace('{','',tostring(split(properties.retentionPolicy.yearlySchedule.retentionDuration,',')[0])))))
    | extend yearLTR = replace('"','',replace(':','',replace('count','',replace('}','',tostring(split(properties.retentionPolicy.yearlySchedule.retentionDuration,',')[1])))))
    | extend yearlyStartDayWeek =  split(tostring(properties.retentionPolicy.yearlySchedule.retentionScheduleWeekly.daysOfTheWeek),'"')[1]
    | extend yearlyStartWeekMonth =  split(tostring(properties.retentionPolicy.yearlySchedule.retentionScheduleWeekly.weeksOfTheMonth),'"')[1]
    | extend yearlyStartMonth =  split(tostring(properties.retentionPolicy.yearlySchedule.monthsOfYear),'"')[1]
    | extend YearlyBackup = strcat("Every month ", yearlyStartWeekMonth, " ", yearlyStartDayWeek, ", retention Duration ", yearLTR, " ", yearDurationType)
    | project policyID,name,DailyBackup,WeeklyBackup,MonthlyBackup,YearlyBackup,daylyLTR,weeklyLTR,monthlyLTR,yearLTR
| join (RecoveryServicesResources 
    | where type in~ ('Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems')
    | extend vaultName = case(type =~ 'microsoft.dataprotection/backupVaults/backupInstances',split(split(id, '/Microsoft.DataProtection/backupVaults/')[1],'/')[0],type =~ 'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',split(split(id, '/Microsoft.RecoveryServices/vaults/')[1],'/')[0],'--')
    | extend dataSourceType = case(type=~'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',properties.backupManagementType,type =~ 'microsoft.dataprotection/backupVaults/backupInstances',properties.dataSourceSetInfo.datasourceType,'--')
    | extend friendlyName = properties.friendlyName
    | extend dsResourceGroup = split(split(properties.dataSourceInfo.resourceID, '/resourceGroups/')[1],'/')[0]
    | extend dsSubscription = split(split(properties.dataSourceInfo.resourceID, '/subscriptions/')[1],'/')[0]
    | extend primaryLocation = properties.dataSourceInfo.resourceLocation
    | extend policyName = case(type =~ 'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',properties.policyName, type =~ 'microsoft.dataprotection/backupVaults/backupInstances', properties.policyInfo.name, '--')
    | extend protectionState = properties.currentProtectionState
    | extend vmProperties = properties
    | where protectionState in~ ('ConfiguringProtection','ProtectionConfigured','ConfiguringProtectionFailed','ProtectionStopped','SoftDeleted','ProtectionError')
    | project id, friendlyName, dataSourceType, dsResourceGroup, dsSubscription, vmProperties, vaultName, protectionState, policyName,primaryLocation)
    on $left.name == $right.policyName
# get all vm details with backup policy
Resources
| where type in~ ('microsoft.compute/virtualmachines','microsoft.classiccompute/virtualmachines') 
| extend resourceId=tolower(id) 
| extend sku = properties.storageProfile.imageReference.sku
| extend publisher = properties.storageProfile.imageReference.publisher
| extend offer = properties.storageProfile.imageReference.offer
| extend ostype = properties.storageProfile.osDisk.osType
| extend hardwareType = properties.hardwareProfile
| join kind = leftouter ( 
    RecoveryServicesResources
    | where type == "microsoft.recoveryservices/vaults/backupfabrics/protectioncontainers/protecteditems"
    | where properties.backupManagementType == "AzureIaasVM"
    | project resourceId = tolower(tostring(properties.sourceResourceId)), backupItemid = id, isBackedUp = isnotempty(id), policyNamex = properties.policyInfo.name, vaultName = case(type =~ 'microsoft.dataprotection/backupVaults/backupInstances',split(split(id, '/Microsoft.DataProtection/backupVaults/')[1],'/')[0],type =~ 'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',split(split(id, '/Microsoft.RecoveryServices/vaults/')[1],'/')[0],'--'), dataSourceType = case(type=~'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',properties.backupManagementType,type =~ 'microsoft.dataprotection/backupVaults/backupInstances',properties.dataSourceSetInfo.datasourceType,'--'), policyName = case(type =~ 'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems',properties.policyName, type =~ 'microsoft.dataprotection/backupVaults/backupInstances', properties.policyInfo.name, '--') ) on resourceId
    | extend isProtected = isnotempty(backupItemid) 
docker run -d --name ms -p 3306:3306  -v mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password mysql

# in wsl2 install mysql-client and connect to the db
mysql --local-infile=1 -uroot -p -h 127.0.0.1 backup_data
# step 01
# on mysql root user
SET GLOBAL local_infile=1;
# step 02
mysql --local-infile=1 -u root -p
# mysql> LOAD DATA LOCAL INFILE  'vm_details_with_backup_policy.csv' INTO TABLE vms FIELDS TERMINATED BY ','  ENCLOSED BY '"' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
#Query OK, 435 rows affected, 438 warnings (0.22 sec)
#Records: 435  Deleted: 0  Skipped: 0  Warnings: 438

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error 224 leica
  • Error 205 radeon software
  • Error 223 обновление bios lenovo g580
  • Error 2044 unhandled ioerrorevent text error 2035 url not found
  • Error 2042 vba excel

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии