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

后端 未结 12 1158
感动是毒
感动是毒 2020-11-27 03:46

I am trying to load data into mysql database using

LOAD DATA LOCAL
INFILE A.txt
INTO DB
LINES TERMINATED BY \'|\';

the topic of this questi

相关标签:
12条回答
  • 2020-11-27 04:39

    Refer to MySQL 8.0 Reference Manual -- 6.1.6 Security Issues with LOAD DATA LOCAL

    On the server side, run

    mysql.server start --local-infile
    

    On the client side, run

    mysql --local-infile database_name -u username -p
    
    0 讨论(0)
  • 2020-11-27 04:41

    Just little addition.

    Found another reincarnation in mysql.connector ver 8.0.16 It now requires allow_local_infile=True or you will see the above error. Worked in prior versions.

    conn = mysql.connector.connect(host=host, user=user, passwd=passwd, database=database, allow_local_infile=True)
    
    0 讨论(0)
  • 2020-11-27 04:46

    If you are using Java8 or + version, JDBC and MySql8 and facing this issue then try this:

    Add parameter to connection string:

    jdbc:mysql://localhost:3306/tempDB?allowLoadLocalInfile=true
    

    Also, set

    local_infile = 1

    in my.cnf file.

    The latest version of mysql-java-connector might be wont allow directly to connect to local file. So with this parameter, you can able to enable it. This works for me.

    0 讨论(0)
  • 2020-11-27 04:48

    You can specify that as an additional option when setting up your client connection:

    mysql -u myuser -p --local-infile somedatabase
    

    This is because that feature opens a security hole. So you have to enable it in an explicit manner in case you really want to use it.

    Both client and server should enable the local-file option. Otherwise it doesn't work.To enable it for files on the server side server add following to the my.cnf configuration file:

    loose-local-infile = 1
    
    0 讨论(0)
  • 2020-11-27 04:49

    The top answers are correct. Please check them direct in MySQL CLI first. If this fixes the problem there, you may want to have it working in Python3 just pass it to the MySQLdb.connectas parameter

    self.connection = MySQLdb.connect(
                        host=host, user=settings_DB.db_config['USER'],
                        port=port, passwd=settings_DB.db_config['PASSWORD'], 
                        db=settings_DB.db_config['NAME'],
                        local_infile=True)
    
    0 讨论(0)
  • 2020-11-27 04:50

    http://dev.mysql.com/doc/refman/5.6/en/load-data-local.html

    Put this in my.cnf - the [client] section should already be there (if you're not too concerned about security).

    [client]
    loose-local-infile=1
    
    0 讨论(0)
提交回复
热议问题