Access denied; you need (at least one of) the SUPER privilege(s) for this operation

后端 未结 12 994
余生分开走
余生分开走 2020-12-12 14:26

So I try to import sql file into rds (1G MEM, 1 CPU). The sql file is like 1.4G

mysql -h xxxx.rds.amazonaws.com -u user -ppass --max-allowed-packet=33554432 db <

相关标签:
12条回答
  • 2020-12-12 14:52

    Just a MacOS extra update for hjpotter92 answer.

    To make sed recognize the pattern in MacOS, you'll have to add a backslash before the = sign, like this:

    sed -i old 's/\DEFINER\=`[^`]*`@`[^`]*`//g' file.sql
    
    0 讨论(0)
  • 2020-12-12 14:55

    Need to set "on" server parameter "log_bin_trust_function_creators" on server side. This one you can easily find on left side blade if it is azure maria db.

    0 讨论(0)
  • 2020-12-12 14:57

    If your dump file doesn't have DEFINER, make sure these lines below are also removed if they're there, or commented-out with --:

    At the start:

    -- SET @@SESSION.SQL_LOG_BIN= 0;
    -- SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '';
    

    At the end:

    -- SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;
    
    0 讨论(0)
  • 2020-12-12 14:58

    Another useful trick is to invoke mysqldump with the option --set-gtid-purged=OFF which does not write the following lines to the output file:

    SET @@SESSION.SQL_LOG_BIN= 0;
    SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '';
    SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;
    

    not sure about the DEFINER one.

    0 讨论(0)
  • 2020-12-12 14:58

    For importing database file in .sql.gz format, remove definer and import using below command

    zcat path_to_db_to_import.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -u user -p new_db_name
    
    1. Earlier, export database in .sql.gz format using below command.

      mysqldump -u user -p old_db | gzip -9 > path_to_db_exported.sql.gz;

    2. Import that exported database and removing definer using below command,

      zcat path_to_db_exported.sql.gz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -u user -p new_db

    0 讨论(0)
  • 2020-12-12 15:00

    Either remove the DEFINER=.. statement from your sqldump file, or replace the user values with CURRENT_USER.

    The MySQL server provided by RDS does not allow a DEFINER syntax for another user (in my experience).

    You can use a sed script to remove them from the file:

    sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i oldfile.sql
    
    0 讨论(0)
提交回复
热议问题