Get the App
SLTechnology News&Howtos  ›  Servers  › 

Permissions for mysql to export data to a file

Shulou Source: shulou.com Published: 2022-06-03 05:00:29 09月21日 Update

Question:

Mysql > select * from products into outfile "/ dbbak/outfile.txt" Fields terminated by "|" Lines terminated by "\ n"

ERROR 1 (HY000): Can't create/write to file'/ dbbak/outfile.txt' (Errcode: 13)

Solve

In the linux of the red hat series, there are restrictions on what daemon can be operated on by selinux, and the select into outfile command of mysql is the daemon of mysql to write the file. Of course, you must have permission to write a file before writing a file. Selinux restricts this permission. If selinux is closed, there is no problem with the execution of this command.

1. Close selinux

Temporary: setenforce 0

Permanent: # vim / etc/sysconfig/selinux

SELINUX=disable

2. Selinux gives the daemon permission to mysql separately.

# getsebool-a view the current permissions on a series of daemons on the system

Tags: Permissions files problems commands processes restrictions situations system permanent data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information NVidia Shulou Technology Redmi