通过命令行将 HTML(使用内联样式)插入到 MySQL
Inserting HTML (with inline styling) to MySQL via command line
我正在尝试自动化 Magento 站点构建,我遇到的挑战之一是通过命令更新数据库中页面的内容。尝试做时:
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES ("<p style="text-align: center;"><a href="http://www.magentocommerce.com/knowledge-base"><img src="{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}" alt="" width="1200" height="630"></a></p>");"
我收到这个错误:
-bash: syntax error near unexpected token `<'
我绝不是 DBA,但我觉得问题是我没有正确转义双引号,或者 运行 进入了终止符 ';'在 HTML 中间失败了。
如有任何帮助,我们将不胜感激。
当你使用它们来标记字符串开始和结束时,你必须用 \
转义双引号
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES (\"<p style=\"text-align: center;\"><a href=\"http://www.magentocommerce.com/knowledge-base\"><img src=\"{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}\" alt=\"\" width=\"1200\" height=\"630\"></a></p>");"
我正在尝试自动化 Magento 站点构建,我遇到的挑战之一是通过命令更新数据库中页面的内容。尝试做时:
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES ("<p style="text-align: center;"><a href="http://www.magentocommerce.com/knowledge-base"><img src="{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}" alt="" width="1200" height="630"></a></p>");"
我收到这个错误:
-bash: syntax error near unexpected token `<'
我绝不是 DBA,但我觉得问题是我没有正确转义双引号,或者 运行 进入了终止符 ';'在 HTML 中间失败了。
如有任何帮助,我们将不胜感激。
当你使用它们来标记字符串开始和结束时,你必须用 \
转义双引号
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES (\"<p style=\"text-align: center;\"><a href=\"http://www.magentocommerce.com/knowledge-base\"><img src=\"{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}\" alt=\"\" width=\"1200\" height=\"630\"></a></p>");"