Mysql command load data infile rights issue

[1] Mysql command load data infile rights issue

Work, often encounter scenarios need to bulk import data between different machines on a mysql database.

To address this problem scenario, mysql there is a very efficient command: load data infile

By data_file load data infile command file data into the table.

Of course, because the problem mysql database rights restrictions, divided into the following situations:

(. 1) root user (root, root specific to non-Linux systems the mysql)

Deployment machine mysql server when importing data, as long as the file to specify the correct path through the load data infile command, generally not a problem.

If the import fails, see the essay " Mysql import file prompt --secure-file-priv option problems "

(2) non-root mysql server machines deployed by introducing load data infile command data, given:

ERROR 1045 (28000): Access denied for user 'xxx'@'xxx' (using password: YES)

This error is usually because there is no FILE Privilege non-root user privileges, query the current user rights can be found in the essay " Mysql users and permissions "

Two solutions:

[1] command with the local parameters. A load data local infile 'filename' into table to import data (strongly recommended)

[2] opened permissions for the current user. When the current user to open FILE Privilege authority, attention:

FILE permissions SELECE / DELETE / UPDATE so different, which is specifically assigned to a table of a db, and FILE is global,

That can only make FILE permissions grant FILE on *. * To 'abcde' @ '%' effect on all tables all db's.

By grant all on db. * To 'abcde' @ '%' could not make the specified user has FILE privileges on the specified db.

According to the principle of least privilege (operating system security concept), this method is not safe, it is not recommended.

(3) non-root infile from the client machine load data local to remote mysql server, given:

ERROR 1148 (42000): The used command is not allowed with this MySQL version

Possible Cause (from mysql reference manual):

If LOAD DATA LOCAL is disabled, either in the server or the client, a client that attempts to issue such a statement receives the following error message:

ERROR 1148: The used command is not allowed with this MySQL version

Visible, for security reasons, the default is not allowed commanded to turn data from a remote client host by the load data

Solution:

For the mysql command-line client, enable LOAD DATA LOCAL by specifying the --local-infile[=1]option, or disable it with the --local-infile=0 option

That is, in a scene from the client host needs to guide people to the data, when the landing mysql, required --local-infile [1 =] explicitly specified parameters, typically in the form of a command:

mysql --local-infile -u user -p passwd

After the successful landing, then perform load data infile 'filename' into table can be.

 

Good Good Study, Day Day Up.

Select the cycle order summary

Guess you like

Origin www.cnblogs.com/Braveliu/p/11411272.html