Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql command with the -H flag is translating column values to HTML safe strings
    text
    copied!<p>There seems to be a feature that has been added in mysql's client command line v14.12 which causes the output columns to be converted to web safe output when the -H flag is being used. This is clearly a safety feature but in my case I am using CONCAT to create intentional html links etc. within some of the columns. Is there a way to turn this apparently new feature off? This problem has arisen in a set of scripts in a shared hosting environment.</p> <p>Extracting a simpler example:</p> <pre><code>echo select \'\&lt;a\&gt;\'\; Results desirably in: select '&lt;a&gt;'; echo select \'\&lt;a\&gt;\'\; | /usr/bin/mysql -s -D database -ppassword Results desirably in: &lt;a&gt; echo select \'\&lt;a\&gt;\'\; | /usr/bin/mysql -H -s -D database -ppassword Results UNDESIRABLY in: &lt;TABLE BORDER=1&gt;&lt;TR&gt;&lt;TH&gt;&amp;lt;a&amp;gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;lt;a&amp;gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt; </code></pre> <p>WHAT I WANT, AND USE TO GET IS</p> <pre><code>&lt;TABLE BORDER=1&gt;&lt;TR&gt;&lt;TH&gt;&lt;a&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;a&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt; </code></pre> <p>which I know isn't valid HTML in this example but in my more complex real examples it is a full set of matched anchor tags with labels not just a single &lt;a&gt; in the cell.</p> <p>I want to continue to use the -H flag as I have a large number of scripts yielding simple internal web readable reports that have links to related reports etc. built with CONCAT in the SQL results.</p> <p>It seems to me that the behavior of -H has changed in 14.12 and I can find no mechanism to switch it off. The --raw/-r flag has no effect on the behavior.</p> <p>Is the -H flag irrecoverably broken or is there a workaround? I'm currently using </p> <pre><code>sed -e 's/\&amp;lt;/&lt;/g' | sed -e 's/\&amp;gt;/&gt;/g' </code></pre> <p>but there must be a better way within the options of the mysql command itself?</p> <p>For reference:</p> <pre><code>/usr/bin/mysql -V /usr/bin/mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2 mysql&gt; status; -------------- /usr/bin/mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2 Connection id: 117586 Current database: database Current user: database@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.0.51a-3ubuntu5.8 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: utf8 Client characterset: latin1 Conn. characterset: latin1 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 1 day 8 hours 22 min 47 sec Threads: 1 Questions: 4222310 Slow queries: 171 Opens: 122761 Flush tables: 1 Open tables: 64 Queries per second avg: 36.222 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload