On the MySQL server, you can use load data infile ‘file_ name’ into table table_ name; Command to save all the data in a text file to the specified table. The most rough example is:
load data infile ‘test. TXT’ into table test_ table;
by default, load data infile has the following behavior for text:
A row corresponds to a record in the database table. The fields are separated by tab key. The value of each field is not enclosed by any characters. The row has no prefix and can be ignored
For example, a line of text:
1 test “xx”
after reading into the database, the value of the third field is “XX”, not XX
Even if the access permission of the test.txt file is changed, such as CHMOD O + R test.txt, the above problems will still occur. To solve this problem, it’s about AppArmor. This is a protection mechanism that limits each program’s access to specific directories and files. In other words, the permission of MySQL program to access this file is limited by AppArmor. For more information about AppArmor, refer to the second link (Wikipedia)
what you can really do is to give the MySQL program permission to read this file. Follow the following steps:
1) open the/etc/appliance.d/usr.sbin.mysqld file
2) at this time, you can see a lot of records about MySQL that can be read and written as directories and files, such as:
/usr/sbin/mysqld {
#Other contents
/var/log/mysql.log rw,
/var/log/mysql.err rw,
#Other contents
#This will be your dir definition
/tmp/ r,
/tmp/** rw,
#Other contents
}
At the end, add the corresponding permissions of the files that need to be read and written, save and exit
3) re import the AppArmor configuration, use the/etc/init.d/apparmor reload command
4) restart mysql, use the service MySQL restart command
so far, the problem should be solved. However, this may be an unsafe solution, which needs to be cautious
Similar Posts:
- Loading local data is disabled; this must be enabled on both the client and server sides
- [Solved] MYSQL ERROR 1290 (HY000): The MySQL server is running with the –secure-file-priv option so it cannot e…
- How to Solve MYSQL Error: Can’t create test file xxx lower-test
- MySQL reports an error using load data local infile
- MySQL Reading table information for completion of table and column names
- [Solved] SQL Error (3621): String or binary data would be truncated The statement has been terminated.
- [troubleshooting] through the remote execution of the script by the scheduling system, the MySQL command not found exception is reported
- [Solved] MySQL Import csv File[Error Code] 1290 – The MySQL server is running with the –secure-file-priv option
- How to Solve MySQL Startup error: mysql-bin.index not found (Errcode: 13)
- [Solved] cannot load from mysql.proc. the table is probably corrupted