首页 > 解决方案 > cPanel - MariaDB - 更新多个数据库中的字段

问题描述

我们有一个包含多个数据库的 cPanel 帐户。

其中一些数据库有一个公共字段,类型文本,作为片段。

这些数据库之一是 MASTER。我们想做的是在我们的 MASTER 数据库的 1 个表中更新此字段,并在其余数据库中更新相同的值。在所有数据库中,表名和字段名都是相同的。

我们已经尝试通过 shell 脚本连接到 DB 以获得新值,然后尝试更新其余数据库。当 que 保存字段的值时,它不安全正确的值。

在一个例子中:

文件查询.txt

SELECT snippet FROM wp_hfcm_scripts where snippet like '%myvalue%';

如果我们连接数据库并运行,那么好的:

mysql -D mybbdd Welcome to the MariaDB monitor.  Commands end with ; or \g. Your MariaDB connection id is 941167 Server version:
10.3.25-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mybbdd]> SELECT snippet FROM wp_hfcm_scripts where snippet like '%myvalue%';
--------------------------------------------------------------------------------------+ | 
<script>  //myvalue 20201007

jQuery(document).ready(function($){ . . .

但是如果我们直接在命令行中启动查询,那么它会以一种奇怪的格式响应:

mysql -D mybbdd < query.sql
snippet
\n\t\tjQuery("#hero-responsive > p, #hero-responsive > br, #info-responsive > p, #info-responsive > br, #checkout-responsive > p, #checkout-responsive > br, #right-checkout-responsive > p, #er\n    \t\t\tjQuery(element).append("<div class='video-checkout'><div

类=''><div . . .

有谁知道为什么会发生这种情况?

标签: shellmariadbcpanelcode-snippets

解决方案


推荐阅读