• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    UsingMySQLtriggersandviewsinAmazonRDS_MySQL

    來源:懂視網 責編:小采 時間:2020-11-09 20:00:15
    文檔

    UsingMySQLtriggersandviewsinAmazonRDS_MySQL

    UsingMySQLtriggersandviewsinAmazonRDS_MySQL:I recently had an opportunity to migrate a customer from a physical server into Amazons RDS environment. In this particular case the customers platform makes extensive use of My
    推薦度:
    導讀UsingMySQLtriggersandviewsinAmazonRDS_MySQL:I recently had an opportunity to migrate a customer from a physical server into Amazons RDS environment. In this particular case the customers platform makes extensive use of My
    I recently had an opportunity to migrate a customer from a physical server into Amazon’s RDS environment. In this particular case the customers’ platform makes extensive use of MySQL triggers and views. I came across two significant issues that prevented me from following Amazon’s documentation, which basically states “use mysqldump” but doesn’t call out a specific method of dealing with MySQL triggers and views.

    Amazon Relational Database Service (Amazon RDS) is a great platform if you’re looking for complete hands-off management of your MySQL environment, but comes at a cost in the area of flexibility, i.e. you don’t have SUPER privilege and this brings up additional challenges.

    1. You need to ensure you set log_bin_trust_function_creators=1 ( by default this is off, 0).
    2. You need to clean up your mysqldump syntax.

    #1 is easy, you simply make a configuration change within the Amazon RDS GUI on the node’s Parameter Group to set log_bin_trust_function_creators=1 and then a restart of your Amazon RDS node. The restart is required since without the SUPER privilege you lose access to changing DYNAMIC variables on the fly. #2 is a little more complex. If you go with vanilla mysqldump (from say a 5.5 mysqldump binary) on a schema that has triggers and views, you will see error 1227, something like this:

    ERROR 1227 (42000) at line 27311: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

    ERROR 1227 ( 42000 ) at line 27311 : Access denied ; you need ( at least one of ) the SUPER privilege ( s ) for this operation

    You’re seeing this message because MySQL in Amazon RDS doesn’t provide the SUPER privilege, and thus you cannot set up a trigger or view to run as a different user — only a user with SUPER can do that.

    mysqldump will generate syntax for a trigger like this:

    DELIMITER ;;/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `after_insert_lead` AFTER INSERT ON `leads` FOR EACH ROW BEGINUPDATE analytics.mapping SET id_lead = NEW.id_lead WHERE mc_email = NEW.email;END */;;DELIMITER ;

    DELIMITER ; ;

    / * ! 50003 CREATE * / / * ! 50017 DEFINER = ` root ` @ ` % ` * / / * ! 50003 TRIGGER ` after_insert_lead ` AFTER INSERT ON ` leads ` FOR EACH ROW BEGIN

    UPDATE analytics .mapping SET id_lead = NEW .id_lead WHERE mc_email = NEW .email ;

    END * / ; ;

    DELIMITER ;

    and for a view like this:

    /*!50001 CREATE ALGORITHM=UNDEFINED *//*!50013 DEFINER=`web`@`%` SQL SECURITY DEFINER *//*!50001 VIEW `admin_user_view` AS SELECT ...

    / * ! 50001 CREATE ALGORITHM = UNDEFINED * /

    / * ! 50013 DEFINER = ` web ` @ ` % ` SQL SECURITY DEFINER * /

    / * ! 50001 VIEW ` admin_user_view ` AS SELECT . . .

    The problem is in the “DEFINER” lines.

    Here’s one method that worked for me:

    1. Identify all the DEFINER lines in your schema. I found it helpful to dump out a –no-data and then weed through that to get a unique list of the DEFINER lines
    2. Create a sed line for each unique DEFINER line (see my example in a moment)
    3. Include this sed line in your dump/load script

    Here’s what my sed matches looked like:

    sed-e 's//*!50017 DEFINER=`root`@`localhost`*///'-e 's//*!50017 DEFINER=`root`@`%`*///'-e 's//*!50017 DEFINER=`web`@`%`*///'-e 's//*!50017 DEFINER=`cron`@`%`*///'-e 's//*!50013 DEFINER=`cron`@`%` SQL SECURITY DEFINER *///'-e 's//*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER *///'-e 's//*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER *///'-e 's//*!50013 DEFINER=`web`@`%` SQL SECURITY DEFINER *///'

    sed

    - e 's//*!50017 DEFINER=`root`@`localhost`*///'

    - e 's//*!50017 DEFINER=`root`@`%`*///'

    - e 's//*!50017 DEFINER=`web`@`%`*///'

    - e 's//*!50017 DEFINER=`cron`@`%`*///'

    - e 's//*!50013 DEFINER=`cron`@`%` SQL SECURITY DEFINER *///'

    - e 's//*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER *///'

    - e 's//*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER *///'

    - e 's//*!50013 DEFINER=`web`@`%` SQL SECURITY DEFINER *///'

    Note: the example above won’t directly work due to WordPress “helpfully” stripping my text… you need to escape the forward slashes and asterisks.

    A big caveat: this method is akin to a brute force method of getting your data into Amazon RDS — you’ve lost the elegance & security of running your triggers and views as separate defined users within the database — they are all now going to run as the user you loaded them in as. If this is a show-stopper for you, contact Percona and I’d be happy to take on your case and develop a more comprehensive solution. :)

    Now all that’s left is to integrate this into your dump flow. Something like this should work:

    mysqldump--host=source| sed-e ... lots of lines| mysql--host=destination

    mysqldump

    -- host = source

    | sed

    - e . . . lots of lines

    | mysql

    -- host = destination

    I hope this helps someone!

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    UsingMySQLtriggersandviewsinAmazonRDS_MySQL

    UsingMySQLtriggersandviewsinAmazonRDS_MySQL:I recently had an opportunity to migrate a customer from a physical server into Amazons RDS environment. In this particular case the customers platform makes extensive use of My
    推薦度:
    標簽: and Amazon mysql
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 色婷婷久久久SWAG精品| 青青热久久国产久精品| 亚洲午夜精品一级在线播放放| 国产精品亚韩精品无码a在线| 亚洲精品国产品国语在线| 亚洲国产精品无码久久久不卡| 亚洲精品在线观看视频| 人妻精品久久久久中文字幕一冢本| 精品欧美一区二区在线看片| 免费91麻豆精品国产自产在线观看 | 亚洲精品无码永久中文字幕| 国产精品麻豆VA在线播放| 国产成人精品无码片区在线观看| 亚洲国产精品激情在线观看| 亚洲色精品vr一区二区三区| 人妻熟妇乱又伦精品视频| 精品欧美激情在线看| 国产精品毛片一区二区| 94久久国产乱子伦精品免费| 久久99精品综合国产首页| 99麻豆久久久国产精品免费| 国产一区二区三精品久久久无广告| 大伊香蕉精品视频在线导航| 国产乱人伦偷精品视频免下载| 亚洲av永久无码精品秋霞电影影院| 四虎成人精品| 日韩精品欧美| 亚洲精品偷拍视频免费观看| 人妻少妇精品系列| 久久久久久国产精品免费免费| 精品无人区无码乱码毛片国产 | 国产精品婷婷午夜在线观看 | 精品国精品无码自拍自在线| 一区二区三区精品| 精品乱人伦一区二区三区| 99精品视频在线| 国产在线精品一区二区不卡| 精品一区二区久久久久久久网站| 国产精品国产三级国产专播 | 欧美一区二区精品| 99久久精品国产毛片|