国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答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
主站蜘蛛池模板: 国产高清在线免费 | 成人a免费视频播放 | 亚洲国产精品久久久久666 | 国产精品亚洲一区二区三区久久 | 羞羞网站在线观看 | 国产精品福利久久久久久小说 | 欧美一级淫片吊带丝袜 | 免费h视频在线观看 | 国产精选视频在线观看 | 欧美在线一区二区 | 亚洲专区欧美 | 国产精品高清久久久久久久 | 99久久亚洲精品影院 | 成人精品视频一区二区在线 | 欧美国产成人精品一区二区三区 | 国产视频网 | 欧美日韩精品国产一区二区 | 亚洲欧美日韩在线2020 | 综合视频在线 | 亚洲综合一区二区三区 | 一区二区视频在线观看高清视频在线 | 欧美一区二区在线播放 | 欧美日韩亚洲一区二区 | 亚洲 欧美 日韩 在线 | 国产在线精品一区二区三区不卡 | 亚洲一区二区三区免费 | 免费看一级黄色毛片 | 国产欧美在线观看精品一区二区 | 一区在线观看 | 日韩aa在线观看 | 黄网站在线观看 | 亚洲欧洲日韩 | 精品国产一区二区三区香蕉 | 成人a网 | 午夜精品久久久久久毛片 | 欧美成人性色生活18黑人 | 日韩精品一区二区三区在线观看l | 91一区二区三区四区五区 | 欧美视频亚洲色图 | 久久精品日日躁夜夜躁欧美 | 国产精品视频久久久久 |