Ошибка 1291 кайрон дизель

Я столкнулся с такой проблемой: Код ошибки: 1290. Сервер MySQL работает с параметром -secure-file-priv, поэтому он не может выполнить этот оператор
когда я пытался выполнить свою инструкцию sql (Windows):

SELECT *
FROM xxxx
WHERE XXX
INTO OUTFILE 'report.csv'
    FIELDS TERMINATED BY '#'
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'

Когда я выполняю его без:

INTO OUTFILE 'report.csv'
    FIELDS TERMINATED BY '#'
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'

Тогда он работает. Кроме того, тот же оператор с INTO OUTFILE xxx работает до того, как я переустановил сервер MySQL.

У кого-нибудь есть идеи, как справиться с этой ошибкой?

Ответ 1

Быстрый ответ, который не требует, чтобы вы редактировали любые файлы конфигурации (и работали как в других операционных системах, так и в Windows), просто найдите каталог, который вы можете сохранить для использования:

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.06 sec)

И затем убедитесь, что вы используете этот каталог в операторе SELECT «INTO OUTFILE:

SELECT *
FROM xxxx
WHERE XXX
INTO OUTFILE '/var/lib/mysql-files/report.csv'
    FIELDS TERMINATED BY '#'
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'

Оригинальный ответ

У меня была такая же проблема с момента обновления с MySQL 5.6.25 до 5.6.26.

В моем случае (в Windows) просмотр службы MySQL56 показывает мне, что файл параметров/настроек, который используется при запуске службы, — C:\ProgramData\MySQL\MySQL Server 5.6\my.ini

Служба MySQL56

Открывая этот файл, я вижу, что опция secure-file-priv была добавлена ​​в эту новую версию MySQL Server со значением по умолчанию:

secure-file-priv="C:/ProgramData/MySQL/MySQL Server 5.6/Uploads"

Вы можете прокомментировать это (если вы находитесь в непроизводственной среде) или поэкспериментировать с изменением настройки. Не забудьте перезапустить службу после внесения изменений.

В качестве альтернативы вы можете попытаться сохранить свой вывод в разрешенной папке (расположение может отличаться в зависимости от вашей установки):

SELECT *
FROM xxxx
WHERE XXX
INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 5.6/Uploads/report.csv'
    FIELDS TERMINATED BY '#'
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'

Ответ 2

Если вы изменили my.ini и перезапустили mysql, и вы все равно получите эту ошибку, проверьте путь к файлу и замените "\" на "/".
Я решил решить проблему после замены.

Ответ 3

Приведенный выше код экспортирует данные без столбцов заголовков, которые являются странными.
Вот как это сделать. Вы должны объединить эти два файла позже, используя текстовый редактор.

SELECT column_name FROM information_schema.columns WHERE table_schema = 'my_app_db' AND table_name = 'customers' INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 5.6/Uploads/customers_heading_cols.csv' FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY ',';

When you update your site with new data from a file, you may see the error “Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it cannot execute this statement”.

Why did it happen all of a sudden? Is your data corrupted?

Not to worry. This is quite easy to fix and usually happens after a MySQL upgrade.

As part of our Server Management Services, we help server owners and webmasters resolve MySQL errors such as this.

Today we will help you fix error code 1290 in a few easy steps.

Why this MySQL error code 1290 appears?

From version 5.7.6 onwards MySQL introduced a new security feature.

This will prevent website attackers from loading malicious data directly into your database.

It is done by restricting the databases to load data from only a single special directory in the server.

That directory is accessible only by the server administrator, and therefore attackers won’t be able to load malware.

By default this directory will be “/var/lib/mysql-files/” in Linux servers.

So, if you have a program or script that loads site data from a different location, MySQL will think that it’s an unauthorized upload attempt, and block it.

Is there any solution?

We have two solutions for your problem with code 1290.

  • One is moving the data file into the directory
  • The other is reconfiguring and restarting MySQL server

Today, let’s discuss these in detail.

Fixing the error by moving the data file into the directory

Recently, one of our customers using Linux approached us with the error code 1290.

He said he was able to load files without failure before. But from the last few days, he is facing this error.

When checked, we found that he recently upgraded his MySQL to 5.7.6 and the default path is restricting the upload.

Let’s see how we fix this.

We asked him to use the query to determine where –secure-file-priv option is.

SHOW VARIABLES LIKE 'secure_file_priv'

This returned a variable along with its value as:

+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+

We asked the customer to use  /var/lib/mysql-files/ as the file path to run LOAD DATA as this is the configured directory and he needs to move the data file here.

Finally, suggested running the LOAD DATA again with the full path.

This fixed the error.

For Windows Users

In Windows, we do the following for fixing the MySQL error 1290

We look for the file being used when the service starts at MySQL57 Windows service.

From there, we get a path similar to C:\ProgramData\MySQL\MySQL Server 5.7\my.ini.

Open the file and under [mysqld] section we can see secure-file-priv along with value as shown:

secure-file-priv=”C:/ProgramData/MySQL/MySQL Server 5.7/Uploads”

This is the path we need to use. So, reissue the LOAD DATA statement with this right path for fixing the error.

Fixing the MySQL error 1290 by reconfiguring and restarting

In some cases, changing the directory won’t solve the issue. In such a case we need to do the following:

For Windows Users

  • Go to start menu and type services.msc then press Ctrl+Shift+Enter to run it as an administrator.
  • Locate the MySQL service and double-click to open its properties dialog.
  • Check the Path to Executable for the –defaults-file option to determine where my.ini file is located.
  • In windows, C:\ProgramData\MySQL\MySQL Server 5.7\my.ini is the default file being used when the service starts.

MySQL error code 1290

Note: It may vary according to various versions

  • Stop the service then close the dialog.
  • From the start menu, take notepad then press Ctrl+Shift+Enter to run it as an administrator.
  • Then open my.ini file previously located in notepad and search the file for secure-file-priv.
  • finally, comment out the line by adding a # in front.

For Linux Users

In Linux, we suggest searching for either of the most common locations: /etc/my.cnf or /etc/mysql/my.cnf.

Search the file for secure-file-priv. We get it along with the value. Comment the line and restart the service.

This will fix the issue.

But, we won’t suggest this as it is not secure.

The secure way is always by moving the data file into the directory.

[Need assistance in fixing MySQL errors? Click here to talk to our experts.]

Conclusion

In short, we discussed in detail on MySQL error code 1290 and saw how our Support Engineers find fix for this in different scenarios.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Ubuntu 16.04 (EASY): Find out where you are allowed to write

mysql> SELECT @@GLOBAL.secure_file_priv;
+---------------------------+
| @@GLOBAL.secure_file_priv |
+---------------------------+
| /var/lib/mysql-files/     |
+---------------------------+
1 row in set (0.00 sec)

Then, just write there

mysql> SELECT * FROM train INTO OUTFILE '/var/lib/mysql-files/test.csv' FIELDS TERMINATED BY ',';
Query OK, 992931 rows affected (1.65 sec)

mysql>

Mac OSX: Mysql installed via MAMP

Find out where you are allowed to write

mysql> SELECT @@GLOBAL.secure_file_priv;
+---------------------------+
| @@GLOBAL.secure_file_priv |
+---------------------------+
| NULL                      |
+---------------------------+
1 row in set (0.00 sec)

NULL means you’re screwed so you have to create the file «~/.my.cnf»

Enable read/write for MySQL installed via MAMP (on Mac):

  1. open «MAMP» use spotlight
  2. click «Stop Servers»
  3. edit ~/.my.cnf (using vi or your favorite editor) and add the following lines:

    $ vi ~/.my.cnf

[mysqld_safe]
[mysqld]
secure_file_priv="/Users/russian_spy/"
  1. click «Start Servers» (in MAMP window)

Now check if it works:

a. start mysql (default MAMP user is root, password is also root)

$ /Applications/MAMP/Library/bin/mysql -u root -p 

b. in mysql look at the white-listed paths

mysql> SELECT @@GLOBAL.secure_file_priv;
+---------------------------+
| @@GLOBAL.secure_file_priv |
+---------------------------+
| /Users/russian_spy/          |
+---------------------------+
1 row in set (0.00 sec)

c. Finally, test by exporting a table train into a CSV file

mysql> SELECT * FROM train INTO OUTFILE '/Users/russian_spy/test.csv' FIELDS TERMINATED BY ',';
Query OK, 992931 rows affected (1.65 sec)

mysql>

Originally published

by

Keith M.

Trying to load some data into mysql using LOAD DATA and encountering the following error?

Error Code: 1290. The MySQL server is running with the —secure-file-priv option so it cannot execute this statement

This error occurs when the server has been configured to use the --secure-file-priv startup option. This option limits where mysql will look for files to a specific directory when processing a LOAD DATA statement.

There are two ways you can resolve this error and get your data loaded.

  • Move the data file into the directory
  • Reconfigure and restart mysql server

Option 1: Move your data file

The file you want to load must be contained within the directory specified by --secure-file-priv. To determine where this is you can query the server variables:

SHOW VARIABLES LIKE 'secure_file_priv'

That query will return a result showing the variable, and it’s value which will be the configured directory. Move your data file into that directory.

Next re-issue your LOAD DATA statement with the full path to the file. The full path is necessary to ensure mysql looks in the correct place. Mysql has some unusual rules for trying to locate the file if you use a relative path.

Option 2: Reconfigure and restart (Windows)

Open the start menu and type services.msc then press Ctrl+Shift+Enter to run it as an administrator.

Open services.msc via start menu.

Locate the MySQL service and double-click to open its properties dialog. Check the Path to Executable for the --defaults-file option to determine where your my.ini file is located. By default, it should be in a path similar to C:\ProgramData\MySQL\MySQL Server 5.7 (adjust appropriately for your specific version).

Locate the my.ini file via the service properties.

Stop the service then close the dialog.

Open the start menu and type notepad then press Ctrl+Shift+Enter to run it as an administrator.

Open the my.ini file you previously located in notepad and search the file for secure-file-priv. Comment out the line by adding a # in front of the line.

Comment out the secure-file-priv option.

Save the file and close notepad.

Re-start the MySQL service using the services management console.

На чтение 2 мин Просмотров 2.9к. Опубликовано

При запуске mysqld сервера вы можете указать параметры программы в файле параметров или в командной строке. Эти параметры предназначены для разблокировки других функций MySQL, изменения переменных или наложения ограничений.

Вот как параметры читаются на сервере MySQL:

  • mysqld считывает параметры из [mysqld] и [server] групп
  • mysqld_safe считывает параметры из [mysqld][server],[mysqld_safe]и [safe_mysqld] групп
  • mysql.server считывает параметры из [mysqld] и [mysql.server] групп.

Вы можете увидеть краткую сводку опций, поддерживаемых MySQL, используя:

Чтобы увидеть полный список, используйте команду:

$ mysqld verbose help

Одна из тех системных переменных, которые можно установить при запуске сервера, это mysqld_secure-file-priv

Содержание

  1. Что такое переменная mysqld_secure-file-priv?
  2. Изменение каталога переменных secure-file-priv
  3. Переменная Diable secure-file-priv

Что такое переменная mysqld_secure-file-priv?

Переменная secure_file_privиспользуется для ограничения эффекта операций импорта и экспорта данных. Пример пораженных операций, выполняемый  LOAD DATA и SELECT ... INTO OUTFILE отчетность и функция LOAD_FILE(). Эти операции разрешены только пользователям, имеющим такую  FILE привилегию.

Чтобы увидеть текущую настройку во время выполнения, используйте SHOW VARIABLESинструкцию.

Войдите в оболочку MySQL как пользователь root

Запускаем

mysql> SHOW VARIABLES LIKE «secure_file_priv»;

+++

| Variable_name    | Value                 |

+++

| secure_file_priv | /var/lib/mysqlfiles/ |

+++

1 row in set

Time: 0.023s

Вы можете видеть, что набор каталогов /var/lib/mysql-files/

Изменение каталога переменных secure-file-priv

Это значение можно изменить в файле опций MySQL в разделе [mysqld] .

Установите переменную в [mysqld] разделе

[mysqld]

securefilepriv=/mysqlfiles

Затем создайте настроенный каталог

sudo mkdir /mysqlfiles

sudo chown R mysql:mysql  /mysqlfiles/

Перезапустите службу MySQL, чтобы изменения вступили в силу.

sudo systemctl restart mysqld

Войдите снова, чтобы подтвердить новую настройку

mysql> SHOW VARIABLES LIKE «secure_file_priv»;

+++

| Variable_name    | Value        |

+++

| secure_file_priv | /mysqlfiles/ |

+++

1 row in set (0.00 sec)

Давайте протестируем, чтобы подтвердить, что мы можем экспортировать по указанному пути.

mysql> SELECT * FROM information_schema.processlist into outfile ‘/tmp/mysql_processes.txt’;

ERROR 1290 (HY000): The MySQL server is running with the securefilepriv option so it cannot execute this statement

Попробуем еще раз написать правильный путь.

mysql> SELECT * FROM information_schema.processlist into outfile ‘/mysqlfiles/mysql_processes.txt’;

Query OK, 1 row affected (0.00 sec)

Переменная Diable secure-file-priv

Чтобы отключить его, установите для переменной значение NULL.

[mysqld]

securefilepriv = «»

Перезапуск службы mysqld

sudo systemctl restart mysqld

Подтвердить после перезапуска службы

mysql> SHOW VARIABLES LIKE «secure_file_priv»;

+++

| Variable_name    | Value |

+++

| secure_file_priv |       |

+++

1 row in set (0.00 sec)

Попробуйте сохранить содержимое QUERY в другую директорию

mysql> SELECT * FROM information_schema.processlist into outfile ‘/tmp/mysql_processes.txt’;

Query OK, 1 row affected (0.00 sec)

Все, спасибо за внимание, теперь вы научились настраивать переменную secure-file-priv

Понравилась статья? Поделить с друзьями:
  • Ошибка 1290 bits
  • Ошибка 129 тойота
  • Ошибка 129 роблокс
  • Ошибка 129 консультант плюс другой пользователь передает параметры
  • Ошибка 129 ивеко дейли