<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://daq00.triumf.ca/MidasWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lindner</id>
	<title>MidasWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://daq00.triumf.ca/MidasWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lindner"/>
	<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php/Special:Contributions/Lindner"/>
	<updated>2026-05-04T12:48:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Mhttpd.js&amp;diff=3608</id>
		<title>Mhttpd.js</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Mhttpd.js&amp;diff=3608"/>
		<updated>2026-03-14T00:41:45Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* About */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Mhttpd|mhttpd MIDAS web server]]&lt;br /&gt;
* [[Custom Page]]&lt;br /&gt;
* [[mjsonrpc|JSON-RPC functions]]&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
&lt;br /&gt;
{{File|name=mhttpd.js}} is a file containing javascript function wrappers for most MIDAS AJAX functions typically used for implementing interactive [[Custom Page]]s for MIDAS experiments. &lt;br /&gt;
Since January 2016, it also contains [[#JSON-RPC interface]] functions (see also [[mjsonrpc]]).&lt;br /&gt;
&lt;br /&gt;
AJAX is a set of web development techniques used to construct interactive web applications:&lt;br /&gt;
* http://en.wikipedia.org/wiki/Ajax_(programming)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;include js lib&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
{{File|name=mhttpd.js}} is typically served by [[mhttpd]] from  {{Filepath|path=$MIDASSYS/resources/mhttpd.js}}, and is included into an html file as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;script src=&#039;mhttpd.js&#039;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A mostly up to date copy of mhttpd.js is linked here:&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/resources/mhttpd.js&lt;br /&gt;
* https://bitbucket.org/tmidas/midas/src/HEAD/resources/mhttpd.js?at=develop&lt;br /&gt;
&lt;br /&gt;
An example for using all mhttpd.js functions is included in the MIDAS distribution under examples/javascript1:&lt;br /&gt;
&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/examples/javascript1/&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/examples/javascript1/example1.html&lt;br /&gt;
&lt;br /&gt;
MIDAS AJAX functions can be accessed directly without using mhttpd.js wrappers (i.e. using the JSON-P script-tag method)&lt;br /&gt;
&lt;br /&gt;
* [[mjsonrpc]] - MIDAS JSON-RPC functions&lt;br /&gt;
* [[AJAX]] - MIDAS AJAX functions&lt;br /&gt;
&lt;br /&gt;
By default, MIDAS AJAX functions assume that the web page was loaded from mhttpd and use relative URLs to access AJAX functions of the same mhttpd. If the web page is loaded from some other source, or needs to talk to a different mhttpd, use the ODBSetURL() function to set the base URL of the target mhttpd. Such cross-site access is normally blocked by web browsers, but recent versions of mhttpd implement the &amp;quot;cross-origin resource sharing&amp;quot; http header to permit such access.&lt;br /&gt;
&lt;br /&gt;
= JSON-RPC interface =&lt;br /&gt;
&lt;br /&gt;
The original AJAX interface to MIDAS is being replaced by a JSON-RPC based interface.&lt;br /&gt;
&lt;br /&gt;
The Javascript functions for use with MIDAS will continue to be documented on this page.&lt;br /&gt;
&lt;br /&gt;
For additional information about the JSON-RPC interface, see [[mjsonrpc]]&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
&lt;br /&gt;
This is a partial list of available javascript functions.&lt;br /&gt;
&lt;br /&gt;
For the full list, and for the full documentation, please go to the doxygen-generated documentation at https://daq.triumf.ca/~daqweb/doc/midas-devel/html/mhttpd_8js.html&lt;br /&gt;
&lt;br /&gt;
Functions to access the MIDAS JSON-RPC API:&lt;br /&gt;
&lt;br /&gt;
* function mjsonrpc_set_url (url) - set the URL of the MIDAS JSON-RPC server, if different from web page URL. Cross-site access is fully supported (see CORS).&lt;br /&gt;
* function mjsonrpc_call (method, params, id) - call arbitrary RPC method&lt;br /&gt;
* function mjsonrpc_start_program (name, id, callback, error_callback)&lt;br /&gt;
* function mjsonrpc_stop_program (name, unique, id, callback, error_callback)&lt;br /&gt;
* function mjsonrpc_db_get_values (paths, id, callback, error_callback) - read ODB values&lt;br /&gt;
* function mjsonrpc_db_paste (paths, values, id, callback, error_callback) - write ODB values&lt;br /&gt;
&lt;br /&gt;
Functions listed below will be replaced by JSON-RPC functions and will become obsolete:&lt;br /&gt;
&lt;br /&gt;
Helper functions:&lt;br /&gt;
&lt;br /&gt;
* function getMouseXY(e) --- removed Feb 2014&lt;br /&gt;
* function XMLHttpRequestGeneric()&lt;br /&gt;
* function ODBExtractRecord(record, key)&lt;br /&gt;
* function ODBEdit(path)&lt;br /&gt;
* function ODBFinishInlineEdit(...)&lt;br /&gt;
* function ODBInlineEditKeydown(...)&lt;br /&gt;
* function ODBInlineEdit(...)&lt;br /&gt;
* function ODBCall(...)&lt;br /&gt;
&lt;br /&gt;
ODB access functions:&lt;br /&gt;
&lt;br /&gt;
* function ODBSetURL(url_of_mhttpd) - set the URL of target mhttpd (if web page is loaded from different source)&lt;br /&gt;
* function ODBSet(path, value, pwdname) - write into ODB&lt;br /&gt;
* function ODBMCopy(paths, callback, format) - read multiple ODB subtrees in ODB, XML or JSON format, asynchronously&lt;br /&gt;
* function ODBMLs(paths, callback) - return ODB directory listings (same as odbedit ls -l)&lt;br /&gt;
&lt;br /&gt;
Obsolete ODB access functions replaced by ODBMCopy():&lt;br /&gt;
&lt;br /&gt;
* function ODBGet(path, format, defval, len, type) - read from ODB&lt;br /&gt;
* function ODBMGet(paths, callback, formats) - read multiple ODB entries&lt;br /&gt;
* function ODBGetRecord(path) - read from ODB&lt;br /&gt;
* function ODBKey(path) - get the description of an ODB entry --- replaced by ODBMKey()&lt;br /&gt;
* function ODBCopy(path, format) - read an ODB subtree in ODB, XML or JSON format&lt;br /&gt;
&lt;br /&gt;
ODB entries creation and modification:&lt;br /&gt;
&lt;br /&gt;
* function ODBMCreate(paths, types, arraylengths, stringlengths, callback) - create multiple ODB entries using db_create_key(path, type)&lt;br /&gt;
* function ODBMResize(paths, arraylengths, stringlengths, callback) - resize multiple ODB arrays, including element size of strings and string arrays&lt;br /&gt;
* function ODBMKey(paths, callback) - read multiple ODB KEYs&lt;br /&gt;
* function ODBMDelete(paths, callback) - delete multiple ODB entries using db_delete_key(path)&lt;br /&gt;
* function ODBMRename(paths, names, callback) - rename multiple ODB entries using db_rename_key(path, name)&lt;br /&gt;
* function ODBMLink(paths, links, callback) - create symbolic links using db_create_link(link, path)&lt;br /&gt;
* function ODBMReorder(paths, indices, callback) - reorder ODB entries using db_reorder_key(path, index)&lt;br /&gt;
&lt;br /&gt;
MIDAS access functions:&lt;br /&gt;
&lt;br /&gt;
* function ODBRpc_rev0(name, rpc, args) --- replaced by ODBRpc()&lt;br /&gt;
* function ODBRpc_rev1(name, rpc, max_reply_length, args) --- replaced by ODBRpc()&lt;br /&gt;
* function ODBRpc(name, command, args, callback, max_reply_length)&lt;br /&gt;
* **function ODBGetMsg(facility,start,number) - get midas messages from midas.log&lt;br /&gt;
* function ODBGenerateMsg(m) - write a midas message&lt;br /&gt;
* function ODBGetAlarms() - get list of active alarms&lt;br /&gt;
&lt;br /&gt;
;Note&lt;br /&gt;
: ** marks functions whose parameters have changed recently (August 2015)&lt;br /&gt;
&lt;br /&gt;
= Summary table =&lt;br /&gt;
&lt;br /&gt;
;Notes&lt;br /&gt;
: &amp;quot;*&amp;quot; marks obsoleted functions. Please avoid using them for new designs.&lt;br /&gt;
: &amp;quot;**&amp;quot; marks functions whose parameters have changed recently (August 2015)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Summary of mhttpd.js functions&lt;br /&gt;
! Function !! XML !! JSON !! JSON-P !! async !! AJAX !! URI encoding !! replaced by (AJAX) !! replaced by (mjsonrpc)&lt;br /&gt;
|-&lt;br /&gt;
| *ODBSet(path, value, pwdname) || no || no || no || no || [[AJAX#jset|cmd=jset]] || by caller, except for &amp;quot;value&amp;quot; || ||mjsonrpc_db_paste&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGet(path, format, defval, len, type) || no || no || no || no || [[AJAX#jget|cmd=jget]] || by caller, except for &amp;quot;format&amp;quot;||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBMGet(paths, callback, formats) || no || no || no || yes || [[AJAX#jget|cmd=jget]] || by caller, including &amp;quot;formats&amp;quot;||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGetRecord(path) || no || no || no || no || [[AJAX#jget|cmd=jget]] with &amp;quot;name=1&amp;quot; || by caller||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBKey(path) || no || yes || no || no || [[AJAX#jkey|cmd=jkey]] || by caller||ODBMKey|| mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| *ODBCopy(path, format) || yes || yes || yes || no || [[AJAX#jcopy|cmd=jcopy]] || by caller, except for &amp;quot;format&amp;quot;||ODBMCopy ||mjsonrpc_db_copy&lt;br /&gt;
|-&lt;br /&gt;
| ODBMCopy(paths, callback, format) || yes || yes || yes || yes || [[AJAX#jcopy|cmd=jcopy]] || internal || ||mjsonrpc_db_copy&lt;br /&gt;
|-&lt;br /&gt;
| ODBMLs(paths, callback) || no || yes || yes || yes || [[AJAX#jcopy|cmd=jcopy]] || internal || ||mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| ODBMCreate(paths, types, arraylengths, stringlengths, callback) || no || yes || yes || yes || [[AJAX#jcreate|cmd=jcreate]] || internal || ||mjsonrpc_db_create&lt;br /&gt;
|-&lt;br /&gt;
| ODBMResize(paths, arraylengths, stringlengths, callback) || no || yes || yes || yes || [[AJAX#jresize|cmd=jresize]] || internal|| ||mjsonrpc_db_resize&lt;br /&gt;
|-&lt;br /&gt;
| ODBMRename(paths, names, callback) || no || yes || yes || yes || [[AJAX#jrename|cmd=jrename]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMKey(paths, callback) || no || yes || yes || yes || [[AJAX#jkey|cmd=jkey&amp;amp;encoding=json]] || internal || ||mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| ODBMDelete(paths, callback) || no || yes || yes || yes || [[AJAX#jdelete|cmd=jdelete]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMLink(paths, links, callback) || no || yes || yes || yes || [[AJAX#jlink|cmd=jlink]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMReorder(paths, indices, callback) || no || yes || yes || yes || [[AJAX#jreorder|cmd=jreorder]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| *ODBRpc_rev0(name, rpc, args) || no || no || no || no || cmd=jrpc_rev0 || || ODBRpc ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| *ODBRpc_rev1(name, rpc, max_reply_length, args) || no || no || no || no || cmd=jrpc_rev1|| ODBRpc || ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| ODBRpc(...) || yes || yes || yes || yes || cmd=jrpc || || ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| **ODBGetMsg(n) || no || no || no || no || [[AJAX#jmsg|cmd=jmsg]] || not needed || ||&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGenerateMsg(m) || no || no || no || no || [[AJAX#jgenmsg|cmd=jgenmsg]] || by caller|| ||mjsonrpc_cm_msg&lt;br /&gt;
|-&lt;br /&gt;
| ODBGetAlarms() || no || no || no || no || [[AJAX#jalm|cmd=jalm]] || -  || ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= ODBSetURL =&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBSetURL(url)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* url - URL of mhttpd we want to talk to.]&lt;br /&gt;
&lt;br /&gt;
Returns: nothing&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ODBSetURL(&amp;quot;http://localhost:8080/&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBSet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbset&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBSet(path, value, pwdname)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
* value - value to write, must NOT be URI-encoded (encoding is done inside ODBSet())&lt;br /&gt;
* pwdname - see [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
Returns: nothing&lt;br /&gt;
&lt;br /&gt;
Error handling: issues an alert() if there are errors.&lt;br /&gt;
&lt;br /&gt;
BUG: may call alert() and require user interaction.&lt;br /&gt;
&lt;br /&gt;
= ODBGet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbget&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGet(path, format, defval, len, type)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path to read, must be URI-encoded&lt;br /&gt;
* format - sprintf format for the data, must NOT be URI-encoded&lt;br /&gt;
* defval - if ODB path does not exist, it is created using [[AJAX#jset]] with this value, must be URI-encoded. Disable this by using &amp;quot;undefined&amp;quot;&lt;br /&gt;
* len - data length for jset&lt;br /&gt;
* type - data type for jset&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBMGet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
See:  http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbmget&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMGet(paths, callback, formats)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - ODB paths to read, must be URI-encoded&lt;br /&gt;
* callback - name of javascript function for asynchronous callback&lt;br /&gt;
* formats - array of strings - sprintf() format strings for each ODB path, see BUGS in [[AJAX#jget]], must by URI-encoded&lt;br /&gt;
&lt;br /&gt;
Valid ODB path targets are: simple variables and arrays (specified as &amp;quot;/eq/foo/var/array[*]&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
ODBMGet for subdirectories does not work (AJAX jget returns correct data, but incorrectly decoded by ODBMGet() javascript code).&lt;br /&gt;
&lt;br /&gt;
ODBMGet for arrays specified without &amp;quot;[*]&amp;quot; is unknown.&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBGetRecord =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jget]] with parameter &amp;quot;name=1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbgetrecord&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetRecord(path)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path to read, must be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* request.responseText&lt;br /&gt;
* use &amp;quot;function ODBExtractRecord(record, key)&amp;quot; to extract ODB values from data retuned by ODBGetRecord().&lt;br /&gt;
&lt;br /&gt;
Valid ODB path targets are: simple variables, array elements (&amp;quot;/eq/foo/var/array[0]&amp;quot;), arrays (specified as &amp;quot;/eq/foo/var/array[*]&amp;quot;) and subdirectories (&amp;quot;/experiment&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      var rec1 = ODBGetRecord(encodeURIComponent(&amp;quot;/Equipment/RpcExample/Variables&amp;quot;));&lt;br /&gt;
      document.getElementById(&#039;foo&#039;).innerHTML = rec1;&lt;br /&gt;
      document.getElementById(&#039;bar&#039;).innerHTML = ODBExtractRecord(rec1, &#039;SLOW[2]&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBKey =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jkey]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBKey(path)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns: javascript object with data fields corresponding to the data fields of MIDAS KEY (midas.h):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&amp;quot;name&amp;quot;:&amp;quot;SLOW&amp;quot;,&amp;quot;type&amp;quot;:&amp;quot;TID_DOUBLE&amp;quot;,&amp;quot;num_values&amp;quot;:&amp;quot;3&amp;quot;,&amp;quot;item_size&amp;quot;:&amp;quot;8&amp;quot;,&amp;quot;last_written&amp;quot;:&amp;quot;1376633931&amp;quot;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var key = new ODBKey(encodeURIComponent(&amp;quot;/Equipment/RpcExample/Variables/SLOW&amp;quot;));&lt;br /&gt;
document.getElementById(&#039;foo&#039;).innerHTML = &amp;quot;name: &amp;quot; + key.name + &amp;quot; type: &amp;quot; + key.type;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBCopy =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBCopy(path, format)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
* format - data format (same as &amp;quot;encoding&amp;quot;), must NOT be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns: request.responseText, use JSON.parse() to decode JSON data.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var data_json = ODBCopy(&amp;quot;/Equipment/RpcExample/Variables&amp;quot;, &amp;quot;json&amp;quot;);&lt;br /&gt;
var obj = JSON.parse(data_json);&lt;br /&gt;
document.getElementById(&#039;json_data0&#039;).innerHTML = obj.SLOW[0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Return value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;SLOW/key&amp;quot; : { &amp;quot;type&amp;quot; : 10, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376634320 },&lt;br /&gt;
  &amp;quot;SLOW&amp;quot; : [ 2357, 1376634320, -8.6602540236010100e+01 ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMCopy =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMCopy(paths, callback, encoding)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to read&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
* encoding - requested data encoding - ODB, XML or JSON, see [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      var paths = [&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Variables&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Variables&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Variables&amp;quot;,&lt;br /&gt;
      ];&lt;br /&gt;
&lt;br /&gt;
      ODBMCopy(paths, load_callback, &amp;quot;json&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
      function load_callback(data)&lt;br /&gt;
      {&lt;br /&gt;
      var obj = JSON.parse(data);&lt;br /&gt;
      document.getElementById(&#039;enableControl1&#039;).innerHTML = obj[0].EnableControl;&lt;br /&gt;
      document.getElementById(&#039;mainSwitch1&#039;).innerHTML = obj[1][&#039;mainSwitch&#039;] + &amp;quot; / &amp;quot; + obj[2][&#039;sysMainSwitch.0&#039;];&lt;br /&gt;
      document.getElementById(&#039;p5v1&#039;).innerHTML = obj[3].current[0];&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSON data returned from ODBMCopy():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[ { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376610870 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;senseVoltage&amp;quot; : [ 5.0500002e+00, 1.1980000e+01, 1.1990000e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;current&amp;quot; : [ 9.0229996e+01, 4.2700000e+00, 5.9899998e+00 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, 25, -128, -128, 25, -128, -128 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;fanSpeed&amp;quot; : [ 3180, 3112, 3236 ] } , { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376603253 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;senseVoltage&amp;quot; : [ 5, 1.1950000e+01, 1.1980000e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;current&amp;quot; : [ 1.4169999e+01, 1.1000000e+00, 8.0000001e-01 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, -128, -128, -128, -128, -128, 22 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;fanSpeed&amp;quot; : [ 3217, 3225, 3213 ] } , { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376596430 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;senseVoltage&amp;quot; : [ 4.9800000e+00, 1.2009999e+01, 1.1969999e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;current&amp;quot; : [ 9.1139999e+01, 4.1999998e+00, 6.0300002e+00 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, 24, -128, -128, 27, -128, -128 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;fanSpeed&amp;quot; : [ 3153, 3067, 3180 ] } ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMLs =&lt;br /&gt;
&lt;br /&gt;
Description: return ODB directory listing with full ODB KEY information (same as odbedit ls -l). It uses the jcopy AJAX method with the JSON &amp;quot;norecurse&amp;quot; option. Same as with odbedit &amp;quot;ls -l&amp;quot;, symlinks are followed and the linked-to values are reported, with the symlink path reported as &amp;quot;link&amp;quot; entry in the ODB KEY (&amp;quot;xxx/key&amp;quot;) section.&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMLs(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to report&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of JSON encoded ODB entries&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Experiment&amp;quot; ]; &lt;br /&gt;
var data = ODBMLs(paths);&lt;br /&gt;
var obj = JSON.Parse(data);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMCreate =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcreate]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMCreate(paths, types, arraylengths, stringlengths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to create&lt;br /&gt;
* types - array of integers - midas data types of created keys (TID_INT, etc)&lt;br /&gt;
* arraylengths - array of integers - &amp;quot;undefined&amp;quot; - or array size to create&lt;br /&gt;
* stringlengths - array of integers - &amp;quot;undefined&amp;quot; - or array of lengths of strings to create&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integers: status of db_create_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var types = [ TID_INT, 0, TID_STRING ]; &lt;br /&gt;
ODBMCreate(paths, types);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMResize =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jresize]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMResize(paths, arraylengths, stringlengths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to resize&lt;br /&gt;
* arraylengths - array of integers - new array size, use &amp;quot;0&amp;quot; for &amp;quot;no change&amp;quot;&lt;br /&gt;
* stringlengths - array of integers - new string length or new element length for string arrays, use &amp;quot;0&amp;quot; for &amp;quot;no change&amp;quot;&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integers: status of db_set_num_values() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var arraylengths = [ 10, 0, 15 ]; &lt;br /&gt;
var stringarrays = [ 0, 0, 16 ];&lt;br /&gt;
ODBMResize(paths, arraylengths, stringlengths);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMKey =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jkey]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMKey(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to read ODB KEYs&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of ODB KEYs&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var data = JSON.parse(ODBMKey(paths));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot;, &amp;quot;/Test/foofoo&amp;quot;, &amp;quot;/Test/barlink&amp;quot;, &amp;quot;/Test/foo10&amp;quot;, &amp;quot;/Test/bar15&amp;quot; ];&lt;br /&gt;
var data = ODBMKey(paths);&lt;br /&gt;
xprint data;&lt;br /&gt;
[ { &amp;quot;name&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;type&amp;quot;:7,&amp;quot;type_name&amp;quot;:&amp;quot;TID_INT&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:4,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;/error&amp;quot;:312 }, { &amp;quot;name&amp;quot;:&amp;quot;bar&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:0,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;/error&amp;quot;:312 }, { &amp;quot;name&amp;quot;:&amp;quot;bar&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:0,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;name&amp;quot;:&amp;quot;foo10&amp;quot;,&amp;quot;type&amp;quot;:7,&amp;quot;type_name&amp;quot;:&amp;quot;TID_INT&amp;quot;,&amp;quot;num_values&amp;quot;:5,&amp;quot;item_size&amp;quot;:4,&amp;quot;last_written&amp;quot;:1380134916 }, { &amp;quot;name&amp;quot;:&amp;quot;bar15&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:7,&amp;quot;item_size&amp;quot;:12,&amp;quot;last_written&amp;quot;:1380134916 } ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMDelete =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jdelete]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMDelete(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to delete&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_delete_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
ODBMDelete(paths);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMRename =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jrename]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMRename(paths, names, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to rename&lt;br /&gt;
* names - array of strings - new names (subject to ODB limitation on key names)&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_rename_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var names = [ &amp;quot;fooxxx&amp;quot;, &amp;quot;zzz&amp;quot;, &amp;quot;barxxx&amp;quot; ];&lt;br /&gt;
ODBMRename(paths, names);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMLink =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jlink]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMLink(paths, links, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths create as symlinks&lt;br /&gt;
* links - array of strings - odb paths of existing odb entries that we link to&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_create_link() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foolink&amp;quot;, &amp;quot;/Test/barlink&amp;quot; ]; &lt;br /&gt;
var links = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/bar&amp;quot; ];&lt;br /&gt;
ODBMLink(paths, links);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= ODBGetMsg =&lt;br /&gt;
Gets message(s) from the MIDAS [[Message System]] or from the [[Chat Page|chat]]. &lt;br /&gt;
&lt;br /&gt;
The parameters of this command have been changed August 2015. See [[#odbgetmsg_old|below]] for older version.&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
&lt;br /&gt;
* function ODBGetMsg(facility, start, number)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
&lt;br /&gt;
* facility - message facility in which messages are written&lt;br /&gt;
:  facility can be &amp;quot;midas&amp;quot; for normal messages or &amp;quot;chat&amp;quot; to load the chat messages&lt;br /&gt;
* start - start time (0=latest message)&lt;br /&gt;
:  the absolute time from when to retrieve messages. Time is defined in unix standard time, i.e. seconds since 1.1.1970. A value of zero has a special meaning of now.&lt;br /&gt;
* number - number of midas messages to return&lt;br /&gt;
 &lt;br /&gt;
Returns: array of strings, if number==1, a single string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
Retrieve the last 100 messages:&lt;br /&gt;
 var data = ODBGetMsg(&amp;quot;midas&amp;quot;,0,100);&lt;br /&gt;
 document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
Each message returned in a separate line in this code contains its UNIX time in the first position, e.g.&lt;br /&gt;
 1449015258 01:14:18.006 2015/12/02 [SC Frontend,TALK] General alarm: COBRA SC quenched&lt;br /&gt;
Now the UNIX time stamp can be saved in the JavaScript code on the page, e.g.&lt;br /&gt;
 last_tstamp = 1449015258&lt;br /&gt;
and in another call we can retrieve the additional 100 message which occurred BEFORE the previous block, i.e.&lt;br /&gt;
 ODBGetMsg(midas, last_tstamp-1, 100)&lt;br /&gt;
The time stamping ensures that no message is lost between the two calls, even if the second call is made many seconds later than the first call. So start&lt;br /&gt;
means start searching for messages at the given UNIX timestamp, and go backwards for n messages.&lt;br /&gt;
&lt;br /&gt;
The function ODBGetMsg returns an array of strings, with one entry per message. This way they can be easily parsed in JavaScript:&lt;br /&gt;
 var msg = ODBGetMsg(midas, 0, 100);&lt;br /&gt;
 for (i=0 ; i&amp;lt;msg.length ; i++)&lt;br /&gt;
    alert(msg[i]);&lt;br /&gt;
&lt;br /&gt;
To see how individual messages are parsed and extracted see function &#039;&#039;msg_append(msg)&#039;&#039; in [[Mhttpd.js|MIDAS Javascript Library]].&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:90%; background-color:whitesmoke&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;odbgetmsg_old&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
; ODBGetMsg (pre August 2015)&lt;br /&gt;
See: [[AJAX#jgenmsg]]&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetMsg(n)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* n - number of midas messages to return&lt;br /&gt;
&lt;br /&gt;
Returns: array of strings, if n==1, as single string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 var data = ODBGetMsg(10);&lt;br /&gt;
 document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= ODBGenMsg =&lt;br /&gt;
Send a message to the MIDAS [[Message System]] or the [[Chat Page|Chat]]. &lt;br /&gt;
&lt;br /&gt;
The parameters of this command have been changed August 2015. See [[#odbgenmsg_old|below]] for older version.&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
&lt;br /&gt;
* function ODBGenMsg(type, facility, user, msg)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* type -  midas message type, numerical value of one of MT_ERROR, MT_INFO, MT_DEBUG, MT_USER, as defined in midas.h. &lt;br /&gt;
: i.e. 1 for MT_ERROR, 2 for MT_INFO etc.&lt;br /&gt;
* facility - facility can be &amp;quot;midas&amp;quot; for the MIDAS message system, or &amp;quot;chat&amp;quot; for the chat message system&lt;br /&gt;
* user -  name of the user who generated the message&lt;br /&gt;
: The user name ends up in the message file inside the [] section to tag each message with an associated user name.&lt;br /&gt;
* message - text written into midas messages&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 ODBGenerateMsg(2, midas, fred, &amp;quot;message text&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:90%; background-color:whitesmoke&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;odbgenmsg_old&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
; ODBGenerateMsg  (pre August 2015)&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jgenmsg]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGenerateMsg(m)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* m - text written into midas messages, must be URI-encoded.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ODBGenerateMsg(encodeURIComponent(&amp;quot;message text&amp;quot;));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBGetAlarms =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jalm]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetAlarms()&lt;br /&gt;
&lt;br /&gt;
Returns: array of strings&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var data = ODBGetAlarms();&lt;br /&gt;
document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom]] [[Category:Javascript library]] [[Category:Ajax]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Mhttpd.js&amp;diff=3607</id>
		<title>Mhttpd.js</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Mhttpd.js&amp;diff=3607"/>
		<updated>2026-03-14T00:41:20Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* About */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Mhttpd|mhttpd MIDAS web server]]&lt;br /&gt;
* [[Custom Page]]&lt;br /&gt;
* [[mjsonrpc|JSON-RPC functions]]&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
&lt;br /&gt;
{{File|name=mhttpd.js}} is a file containing javascript function wrappers for most MIDAS AJAX functions typically used for implementing interactive [[Custom Page]]s for MIDAS experiments. &lt;br /&gt;
Since January 2016, it also contains [[#JSON-RPC interface]] functions (see also [[mjsonrpc]]).&lt;br /&gt;
&lt;br /&gt;
AJAX is a set of web development techniques used to construct interactive web applications:&lt;br /&gt;
* http://en.wikipedia.org/wiki/Ajax_(programming)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;include js lib&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
{{File|name=mhttpd.js}} is typically served by [[mhttpd]] from  {{Filepath|path=$MIDASSYS/resources/mhttpd.js}}, and is included into an html file as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;script src=&#039;mhttpd.js&#039;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A mostly up to date copy of mhttpd.js is linked here:&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/resources/mhttpd.js&lt;br /&gt;
* https://bitbucket.org/tmidas/midas/src/HEAD/resources/mhttpd.js?at=develop&lt;br /&gt;
&lt;br /&gt;
An example for using all mhttpd.js functions is included in the MIDAS distribution under examples/javascript1:&lt;br /&gt;
&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/examples/javascript1/&lt;br /&gt;
* https://daq.triumf.ca/~daqweb/doc/midas-develop/examples/javascript1/example.html&lt;br /&gt;
&lt;br /&gt;
MIDAS AJAX functions can be accessed directly without using mhttpd.js wrappers (i.e. using the JSON-P script-tag method)&lt;br /&gt;
&lt;br /&gt;
* [[mjsonrpc]] - MIDAS JSON-RPC functions&lt;br /&gt;
* [[AJAX]] - MIDAS AJAX functions&lt;br /&gt;
&lt;br /&gt;
By default, MIDAS AJAX functions assume that the web page was loaded from mhttpd and use relative URLs to access AJAX functions of the same mhttpd. If the web page is loaded from some other source, or needs to talk to a different mhttpd, use the ODBSetURL() function to set the base URL of the target mhttpd. Such cross-site access is normally blocked by web browsers, but recent versions of mhttpd implement the &amp;quot;cross-origin resource sharing&amp;quot; http header to permit such access.&lt;br /&gt;
&lt;br /&gt;
= JSON-RPC interface =&lt;br /&gt;
&lt;br /&gt;
The original AJAX interface to MIDAS is being replaced by a JSON-RPC based interface.&lt;br /&gt;
&lt;br /&gt;
The Javascript functions for use with MIDAS will continue to be documented on this page.&lt;br /&gt;
&lt;br /&gt;
For additional information about the JSON-RPC interface, see [[mjsonrpc]]&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
&lt;br /&gt;
This is a partial list of available javascript functions.&lt;br /&gt;
&lt;br /&gt;
For the full list, and for the full documentation, please go to the doxygen-generated documentation at https://daq.triumf.ca/~daqweb/doc/midas-devel/html/mhttpd_8js.html&lt;br /&gt;
&lt;br /&gt;
Functions to access the MIDAS JSON-RPC API:&lt;br /&gt;
&lt;br /&gt;
* function mjsonrpc_set_url (url) - set the URL of the MIDAS JSON-RPC server, if different from web page URL. Cross-site access is fully supported (see CORS).&lt;br /&gt;
* function mjsonrpc_call (method, params, id) - call arbitrary RPC method&lt;br /&gt;
* function mjsonrpc_start_program (name, id, callback, error_callback)&lt;br /&gt;
* function mjsonrpc_stop_program (name, unique, id, callback, error_callback)&lt;br /&gt;
* function mjsonrpc_db_get_values (paths, id, callback, error_callback) - read ODB values&lt;br /&gt;
* function mjsonrpc_db_paste (paths, values, id, callback, error_callback) - write ODB values&lt;br /&gt;
&lt;br /&gt;
Functions listed below will be replaced by JSON-RPC functions and will become obsolete:&lt;br /&gt;
&lt;br /&gt;
Helper functions:&lt;br /&gt;
&lt;br /&gt;
* function getMouseXY(e) --- removed Feb 2014&lt;br /&gt;
* function XMLHttpRequestGeneric()&lt;br /&gt;
* function ODBExtractRecord(record, key)&lt;br /&gt;
* function ODBEdit(path)&lt;br /&gt;
* function ODBFinishInlineEdit(...)&lt;br /&gt;
* function ODBInlineEditKeydown(...)&lt;br /&gt;
* function ODBInlineEdit(...)&lt;br /&gt;
* function ODBCall(...)&lt;br /&gt;
&lt;br /&gt;
ODB access functions:&lt;br /&gt;
&lt;br /&gt;
* function ODBSetURL(url_of_mhttpd) - set the URL of target mhttpd (if web page is loaded from different source)&lt;br /&gt;
* function ODBSet(path, value, pwdname) - write into ODB&lt;br /&gt;
* function ODBMCopy(paths, callback, format) - read multiple ODB subtrees in ODB, XML or JSON format, asynchronously&lt;br /&gt;
* function ODBMLs(paths, callback) - return ODB directory listings (same as odbedit ls -l)&lt;br /&gt;
&lt;br /&gt;
Obsolete ODB access functions replaced by ODBMCopy():&lt;br /&gt;
&lt;br /&gt;
* function ODBGet(path, format, defval, len, type) - read from ODB&lt;br /&gt;
* function ODBMGet(paths, callback, formats) - read multiple ODB entries&lt;br /&gt;
* function ODBGetRecord(path) - read from ODB&lt;br /&gt;
* function ODBKey(path) - get the description of an ODB entry --- replaced by ODBMKey()&lt;br /&gt;
* function ODBCopy(path, format) - read an ODB subtree in ODB, XML or JSON format&lt;br /&gt;
&lt;br /&gt;
ODB entries creation and modification:&lt;br /&gt;
&lt;br /&gt;
* function ODBMCreate(paths, types, arraylengths, stringlengths, callback) - create multiple ODB entries using db_create_key(path, type)&lt;br /&gt;
* function ODBMResize(paths, arraylengths, stringlengths, callback) - resize multiple ODB arrays, including element size of strings and string arrays&lt;br /&gt;
* function ODBMKey(paths, callback) - read multiple ODB KEYs&lt;br /&gt;
* function ODBMDelete(paths, callback) - delete multiple ODB entries using db_delete_key(path)&lt;br /&gt;
* function ODBMRename(paths, names, callback) - rename multiple ODB entries using db_rename_key(path, name)&lt;br /&gt;
* function ODBMLink(paths, links, callback) - create symbolic links using db_create_link(link, path)&lt;br /&gt;
* function ODBMReorder(paths, indices, callback) - reorder ODB entries using db_reorder_key(path, index)&lt;br /&gt;
&lt;br /&gt;
MIDAS access functions:&lt;br /&gt;
&lt;br /&gt;
* function ODBRpc_rev0(name, rpc, args) --- replaced by ODBRpc()&lt;br /&gt;
* function ODBRpc_rev1(name, rpc, max_reply_length, args) --- replaced by ODBRpc()&lt;br /&gt;
* function ODBRpc(name, command, args, callback, max_reply_length)&lt;br /&gt;
* **function ODBGetMsg(facility,start,number) - get midas messages from midas.log&lt;br /&gt;
* function ODBGenerateMsg(m) - write a midas message&lt;br /&gt;
* function ODBGetAlarms() - get list of active alarms&lt;br /&gt;
&lt;br /&gt;
;Note&lt;br /&gt;
: ** marks functions whose parameters have changed recently (August 2015)&lt;br /&gt;
&lt;br /&gt;
= Summary table =&lt;br /&gt;
&lt;br /&gt;
;Notes&lt;br /&gt;
: &amp;quot;*&amp;quot; marks obsoleted functions. Please avoid using them for new designs.&lt;br /&gt;
: &amp;quot;**&amp;quot; marks functions whose parameters have changed recently (August 2015)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Summary of mhttpd.js functions&lt;br /&gt;
! Function !! XML !! JSON !! JSON-P !! async !! AJAX !! URI encoding !! replaced by (AJAX) !! replaced by (mjsonrpc)&lt;br /&gt;
|-&lt;br /&gt;
| *ODBSet(path, value, pwdname) || no || no || no || no || [[AJAX#jset|cmd=jset]] || by caller, except for &amp;quot;value&amp;quot; || ||mjsonrpc_db_paste&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGet(path, format, defval, len, type) || no || no || no || no || [[AJAX#jget|cmd=jget]] || by caller, except for &amp;quot;format&amp;quot;||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBMGet(paths, callback, formats) || no || no || no || yes || [[AJAX#jget|cmd=jget]] || by caller, including &amp;quot;formats&amp;quot;||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGetRecord(path) || no || no || no || no || [[AJAX#jget|cmd=jget]] with &amp;quot;name=1&amp;quot; || by caller||ODBMCopy ||mjsonrpc_db_get_values&lt;br /&gt;
|-&lt;br /&gt;
| *ODBKey(path) || no || yes || no || no || [[AJAX#jkey|cmd=jkey]] || by caller||ODBMKey|| mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| *ODBCopy(path, format) || yes || yes || yes || no || [[AJAX#jcopy|cmd=jcopy]] || by caller, except for &amp;quot;format&amp;quot;||ODBMCopy ||mjsonrpc_db_copy&lt;br /&gt;
|-&lt;br /&gt;
| ODBMCopy(paths, callback, format) || yes || yes || yes || yes || [[AJAX#jcopy|cmd=jcopy]] || internal || ||mjsonrpc_db_copy&lt;br /&gt;
|-&lt;br /&gt;
| ODBMLs(paths, callback) || no || yes || yes || yes || [[AJAX#jcopy|cmd=jcopy]] || internal || ||mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| ODBMCreate(paths, types, arraylengths, stringlengths, callback) || no || yes || yes || yes || [[AJAX#jcreate|cmd=jcreate]] || internal || ||mjsonrpc_db_create&lt;br /&gt;
|-&lt;br /&gt;
| ODBMResize(paths, arraylengths, stringlengths, callback) || no || yes || yes || yes || [[AJAX#jresize|cmd=jresize]] || internal|| ||mjsonrpc_db_resize&lt;br /&gt;
|-&lt;br /&gt;
| ODBMRename(paths, names, callback) || no || yes || yes || yes || [[AJAX#jrename|cmd=jrename]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMKey(paths, callback) || no || yes || yes || yes || [[AJAX#jkey|cmd=jkey&amp;amp;encoding=json]] || internal || ||mjsonrpc_db_ls&lt;br /&gt;
|-&lt;br /&gt;
| ODBMDelete(paths, callback) || no || yes || yes || yes || [[AJAX#jdelete|cmd=jdelete]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMLink(paths, links, callback) || no || yes || yes || yes || [[AJAX#jlink|cmd=jlink]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| ODBMReorder(paths, indices, callback) || no || yes || yes || yes || [[AJAX#jreorder|cmd=jreorder]] || internal || ||&lt;br /&gt;
|-&lt;br /&gt;
| *ODBRpc_rev0(name, rpc, args) || no || no || no || no || cmd=jrpc_rev0 || || ODBRpc ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| *ODBRpc_rev1(name, rpc, max_reply_length, args) || no || no || no || no || cmd=jrpc_rev1|| ODBRpc || ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| ODBRpc(...) || yes || yes || yes || yes || cmd=jrpc || || ||mjsonrpc_call&lt;br /&gt;
|-&lt;br /&gt;
| **ODBGetMsg(n) || no || no || no || no || [[AJAX#jmsg|cmd=jmsg]] || not needed || ||&lt;br /&gt;
|-&lt;br /&gt;
| *ODBGenerateMsg(m) || no || no || no || no || [[AJAX#jgenmsg|cmd=jgenmsg]] || by caller|| ||mjsonrpc_cm_msg&lt;br /&gt;
|-&lt;br /&gt;
| ODBGetAlarms() || no || no || no || no || [[AJAX#jalm|cmd=jalm]] || -  || ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= ODBSetURL =&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBSetURL(url)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* url - URL of mhttpd we want to talk to.]&lt;br /&gt;
&lt;br /&gt;
Returns: nothing&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ODBSetURL(&amp;quot;http://localhost:8080/&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBSet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbset&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBSet(path, value, pwdname)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
* value - value to write, must NOT be URI-encoded (encoding is done inside ODBSet())&lt;br /&gt;
* pwdname - see [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
Returns: nothing&lt;br /&gt;
&lt;br /&gt;
Error handling: issues an alert() if there are errors.&lt;br /&gt;
&lt;br /&gt;
BUG: may call alert() and require user interaction.&lt;br /&gt;
&lt;br /&gt;
= ODBGet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jset]]&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbget&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGet(path, format, defval, len, type)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path to read, must be URI-encoded&lt;br /&gt;
* format - sprintf format for the data, must NOT be URI-encoded&lt;br /&gt;
* defval - if ODB path does not exist, it is created using [[AJAX#jset]] with this value, must be URI-encoded. Disable this by using &amp;quot;undefined&amp;quot;&lt;br /&gt;
* len - data length for jset&lt;br /&gt;
* type - data type for jset&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBMGet =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
See:  http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbmget&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMGet(paths, callback, formats)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - ODB paths to read, must be URI-encoded&lt;br /&gt;
* callback - name of javascript function for asynchronous callback&lt;br /&gt;
* formats - array of strings - sprintf() format strings for each ODB path, see BUGS in [[AJAX#jget]], must by URI-encoded&lt;br /&gt;
&lt;br /&gt;
Valid ODB path targets are: simple variables and arrays (specified as &amp;quot;/eq/foo/var/array[*]&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
ODBMGet for subdirectories does not work (AJAX jget returns correct data, but incorrectly decoded by ODBMGet() javascript code).&lt;br /&gt;
&lt;br /&gt;
ODBMGet for arrays specified without &amp;quot;[*]&amp;quot; is unknown.&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBGetRecord =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jget]] with parameter &amp;quot;name=1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See: http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/RC_mhttpd_custom_ODB_access.html#RC_mhttpd_custom_odbgetrecord&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetRecord(path)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path to read, must be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* request.responseText&lt;br /&gt;
* use &amp;quot;function ODBExtractRecord(record, key)&amp;quot; to extract ODB values from data retuned by ODBGetRecord().&lt;br /&gt;
&lt;br /&gt;
Valid ODB path targets are: simple variables, array elements (&amp;quot;/eq/foo/var/array[0]&amp;quot;), arrays (specified as &amp;quot;/eq/foo/var/array[*]&amp;quot;) and subdirectories (&amp;quot;/experiment&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      var rec1 = ODBGetRecord(encodeURIComponent(&amp;quot;/Equipment/RpcExample/Variables&amp;quot;));&lt;br /&gt;
      document.getElementById(&#039;foo&#039;).innerHTML = rec1;&lt;br /&gt;
      document.getElementById(&#039;bar&#039;).innerHTML = ODBExtractRecord(rec1, &#039;SLOW[2]&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* BUG: read the BUG sections in [[AJAX#jget]]&lt;br /&gt;
&lt;br /&gt;
= ODBKey =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jkey]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBKey(path)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns: javascript object with data fields corresponding to the data fields of MIDAS KEY (midas.h):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&amp;quot;name&amp;quot;:&amp;quot;SLOW&amp;quot;,&amp;quot;type&amp;quot;:&amp;quot;TID_DOUBLE&amp;quot;,&amp;quot;num_values&amp;quot;:&amp;quot;3&amp;quot;,&amp;quot;item_size&amp;quot;:&amp;quot;8&amp;quot;,&amp;quot;last_written&amp;quot;:&amp;quot;1376633931&amp;quot;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var key = new ODBKey(encodeURIComponent(&amp;quot;/Equipment/RpcExample/Variables/SLOW&amp;quot;));&lt;br /&gt;
document.getElementById(&#039;foo&#039;).innerHTML = &amp;quot;name: &amp;quot; + key.name + &amp;quot; type: &amp;quot; + key.type;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBCopy =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBCopy(path, format)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* path - ODB path, must be URI-encoded&lt;br /&gt;
* format - data format (same as &amp;quot;encoding&amp;quot;), must NOT be URI-encoded&lt;br /&gt;
&lt;br /&gt;
Returns: request.responseText, use JSON.parse() to decode JSON data.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var data_json = ODBCopy(&amp;quot;/Equipment/RpcExample/Variables&amp;quot;, &amp;quot;json&amp;quot;);&lt;br /&gt;
var obj = JSON.parse(data_json);&lt;br /&gt;
document.getElementById(&#039;json_data0&#039;).innerHTML = obj.SLOW[0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Return value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;SLOW/key&amp;quot; : { &amp;quot;type&amp;quot; : 10, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376634320 },&lt;br /&gt;
  &amp;quot;SLOW&amp;quot; : [ 2357, 1376634320, -8.6602540236010100e+01 ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMCopy =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMCopy(paths, callback, encoding)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to read&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
* encoding - requested data encoding - ODB, XML or JSON, see [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      var paths = [&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme01/Variables&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme02/Variables&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Settings/EnableControl&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Settings/mainSwitch&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Readback/sysMainSwitch.0&amp;quot;,&lt;br /&gt;
      &amp;quot;/Equipment/deapvme03/Variables&amp;quot;,&lt;br /&gt;
      ];&lt;br /&gt;
&lt;br /&gt;
      ODBMCopy(paths, load_callback, &amp;quot;json&amp;quot;);&lt;br /&gt;
...&lt;br /&gt;
      function load_callback(data)&lt;br /&gt;
      {&lt;br /&gt;
      var obj = JSON.parse(data);&lt;br /&gt;
      document.getElementById(&#039;enableControl1&#039;).innerHTML = obj[0].EnableControl;&lt;br /&gt;
      document.getElementById(&#039;mainSwitch1&#039;).innerHTML = obj[1][&#039;mainSwitch&#039;] + &amp;quot; / &amp;quot; + obj[2][&#039;sysMainSwitch.0&#039;];&lt;br /&gt;
      document.getElementById(&#039;p5v1&#039;).innerHTML = obj[3].current[0];&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSON data returned from ODBMCopy():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[ { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376610870 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;senseVoltage&amp;quot; : [ 5.0500002e+00, 1.1980000e+01, 1.1990000e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;current&amp;quot; : [ 9.0229996e+01, 4.2700000e+00, 5.9899998e+00 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, 25, -128, -128, 25, -128, -128 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681747 }, &amp;quot;fanSpeed&amp;quot; : [ 3180, 3112, 3236 ] } , { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376603253 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;senseVoltage&amp;quot; : [ 5, 1.1950000e+01, 1.1980000e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;current&amp;quot; : [ 1.4169999e+01, 1.1000000e+00, 8.0000001e-01 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, -128, -128, -128, -128, -128, 22 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681750 }, &amp;quot;fanSpeed&amp;quot; : [ 3217, 3225, 3213 ] } , { &amp;quot;EnableControl/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1375145722 }, &amp;quot;EnableControl&amp;quot; : 1 } , { &amp;quot;mainSwitch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376596430 }, &amp;quot;mainSwitch&amp;quot; : 1 } , { &amp;quot;sysMainSwitch.0/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sysMainSwitch.0&amp;quot; : 1 } , { &amp;quot;switch/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;switch&amp;quot; : [ 1, 1, 1 ], &amp;quot;status/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;status&amp;quot; : [ 1, 1, 1 ], &amp;quot;demandVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;demandVoltage&amp;quot; : [ 5, 12, 12 ], &amp;quot;senseVoltage/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;senseVoltage&amp;quot; : [ 4.9800000e+00, 1.2009999e+01, 1.1969999e+01 ], &amp;quot;current/key&amp;quot; : { &amp;quot;type&amp;quot; : 9, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;current&amp;quot; : [ 9.1139999e+01, 4.1999998e+00, 6.0300002e+00 ], &amp;quot;sparkCount/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sparkCount&amp;quot; : [ 0, 0, 0 ], &amp;quot;sensorTemperature/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 8, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;sensorTemperature&amp;quot; : [ -128, -128, 24, -128, -128, 27, -128, -128 ], &amp;quot;fanSpeed/key&amp;quot; : { &amp;quot;type&amp;quot; : 7, &amp;quot;num_values&amp;quot; : 3, &amp;quot;last_written&amp;quot; : 1376681752 }, &amp;quot;fanSpeed&amp;quot; : [ 3153, 3067, 3180 ] } ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMLs =&lt;br /&gt;
&lt;br /&gt;
Description: return ODB directory listing with full ODB KEY information (same as odbedit ls -l). It uses the jcopy AJAX method with the JSON &amp;quot;norecurse&amp;quot; option. Same as with odbedit &amp;quot;ls -l&amp;quot;, symlinks are followed and the linked-to values are reported, with the symlink path reported as &amp;quot;link&amp;quot; entry in the ODB KEY (&amp;quot;xxx/key&amp;quot;) section.&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcopy]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMLs(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to report&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of JSON encoded ODB entries&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Experiment&amp;quot; ]; &lt;br /&gt;
var data = ODBMLs(paths);&lt;br /&gt;
var obj = JSON.Parse(data);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMCreate =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jcreate]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMCreate(paths, types, arraylengths, stringlengths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to create&lt;br /&gt;
* types - array of integers - midas data types of created keys (TID_INT, etc)&lt;br /&gt;
* arraylengths - array of integers - &amp;quot;undefined&amp;quot; - or array size to create&lt;br /&gt;
* stringlengths - array of integers - &amp;quot;undefined&amp;quot; - or array of lengths of strings to create&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integers: status of db_create_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var types = [ TID_INT, 0, TID_STRING ]; &lt;br /&gt;
ODBMCreate(paths, types);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMResize =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jresize]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMResize(paths, arraylengths, stringlengths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to resize&lt;br /&gt;
* arraylengths - array of integers - new array size, use &amp;quot;0&amp;quot; for &amp;quot;no change&amp;quot;&lt;br /&gt;
* stringlengths - array of integers - new string length or new element length for string arrays, use &amp;quot;0&amp;quot; for &amp;quot;no change&amp;quot;&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integers: status of db_set_num_values() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var arraylengths = [ 10, 0, 15 ]; &lt;br /&gt;
var stringarrays = [ 0, 0, 16 ];&lt;br /&gt;
ODBMResize(paths, arraylengths, stringlengths);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMKey =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jkey]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMKey(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to read ODB KEYs&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of ODB KEYs&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var data = JSON.parse(ODBMKey(paths));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot;, &amp;quot;/Test/foofoo&amp;quot;, &amp;quot;/Test/barlink&amp;quot;, &amp;quot;/Test/foo10&amp;quot;, &amp;quot;/Test/bar15&amp;quot; ];&lt;br /&gt;
var data = ODBMKey(paths);&lt;br /&gt;
xprint data;&lt;br /&gt;
[ { &amp;quot;name&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;type&amp;quot;:7,&amp;quot;type_name&amp;quot;:&amp;quot;TID_INT&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:4,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;/error&amp;quot;:312 }, { &amp;quot;name&amp;quot;:&amp;quot;bar&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:0,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;/error&amp;quot;:312 }, { &amp;quot;name&amp;quot;:&amp;quot;bar&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:1,&amp;quot;item_size&amp;quot;:0,&amp;quot;last_written&amp;quot;:0 }, { &amp;quot;name&amp;quot;:&amp;quot;foo10&amp;quot;,&amp;quot;type&amp;quot;:7,&amp;quot;type_name&amp;quot;:&amp;quot;TID_INT&amp;quot;,&amp;quot;num_values&amp;quot;:5,&amp;quot;item_size&amp;quot;:4,&amp;quot;last_written&amp;quot;:1380134916 }, { &amp;quot;name&amp;quot;:&amp;quot;bar15&amp;quot;,&amp;quot;type&amp;quot;:12,&amp;quot;type_name&amp;quot;:&amp;quot;TID_STRING&amp;quot;,&amp;quot;num_values&amp;quot;:7,&amp;quot;item_size&amp;quot;:12,&amp;quot;last_written&amp;quot;:1380134916 } ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMDelete =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jdelete]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMDelete(paths, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to delete&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_delete_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
ODBMDelete(paths);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMRename =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jrename]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMRename(paths, names, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths to rename&lt;br /&gt;
* names - array of strings - new names (subject to ODB limitation on key names)&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_rename_key() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/noexistant&amp;quot;, &amp;quot;/Test/bar&amp;quot; ]; &lt;br /&gt;
var names = [ &amp;quot;fooxxx&amp;quot;, &amp;quot;zzz&amp;quot;, &amp;quot;barxxx&amp;quot; ];&lt;br /&gt;
ODBMRename(paths, names);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBMLink =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jlink]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBMLink(paths, links, callback)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* paths - array of strings - odb paths create as symlinks&lt;br /&gt;
* links - array of strings - odb paths of existing odb entries that we link to&lt;br /&gt;
* callback - name of javascript function for asynchronous callback, or &amp;quot;undefined&amp;quot; for synchronous return&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
* array of integer: status of db_create_link() for each element of &amp;quot;paths&amp;quot;&lt;br /&gt;
* synchronous: returns request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
* asynchronous: calls the callback function with a single argument set to request.responseText, use JSON.parse() to decode JSON data&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var paths = [ &amp;quot;/Test/foolink&amp;quot;, &amp;quot;/Test/barlink&amp;quot; ]; &lt;br /&gt;
var links = [ &amp;quot;/Test/foo&amp;quot;, &amp;quot;/Test/bar&amp;quot; ];&lt;br /&gt;
ODBMLink(paths, links);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= ODBGetMsg =&lt;br /&gt;
Gets message(s) from the MIDAS [[Message System]] or from the [[Chat Page|chat]]. &lt;br /&gt;
&lt;br /&gt;
The parameters of this command have been changed August 2015. See [[#odbgetmsg_old|below]] for older version.&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
&lt;br /&gt;
* function ODBGetMsg(facility, start, number)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
&lt;br /&gt;
* facility - message facility in which messages are written&lt;br /&gt;
:  facility can be &amp;quot;midas&amp;quot; for normal messages or &amp;quot;chat&amp;quot; to load the chat messages&lt;br /&gt;
* start - start time (0=latest message)&lt;br /&gt;
:  the absolute time from when to retrieve messages. Time is defined in unix standard time, i.e. seconds since 1.1.1970. A value of zero has a special meaning of now.&lt;br /&gt;
* number - number of midas messages to return&lt;br /&gt;
 &lt;br /&gt;
Returns: array of strings, if number==1, a single string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
Retrieve the last 100 messages:&lt;br /&gt;
 var data = ODBGetMsg(&amp;quot;midas&amp;quot;,0,100);&lt;br /&gt;
 document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
Each message returned in a separate line in this code contains its UNIX time in the first position, e.g.&lt;br /&gt;
 1449015258 01:14:18.006 2015/12/02 [SC Frontend,TALK] General alarm: COBRA SC quenched&lt;br /&gt;
Now the UNIX time stamp can be saved in the JavaScript code on the page, e.g.&lt;br /&gt;
 last_tstamp = 1449015258&lt;br /&gt;
and in another call we can retrieve the additional 100 message which occurred BEFORE the previous block, i.e.&lt;br /&gt;
 ODBGetMsg(midas, last_tstamp-1, 100)&lt;br /&gt;
The time stamping ensures that no message is lost between the two calls, even if the second call is made many seconds later than the first call. So start&lt;br /&gt;
means start searching for messages at the given UNIX timestamp, and go backwards for n messages.&lt;br /&gt;
&lt;br /&gt;
The function ODBGetMsg returns an array of strings, with one entry per message. This way they can be easily parsed in JavaScript:&lt;br /&gt;
 var msg = ODBGetMsg(midas, 0, 100);&lt;br /&gt;
 for (i=0 ; i&amp;lt;msg.length ; i++)&lt;br /&gt;
    alert(msg[i]);&lt;br /&gt;
&lt;br /&gt;
To see how individual messages are parsed and extracted see function &#039;&#039;msg_append(msg)&#039;&#039; in [[Mhttpd.js|MIDAS Javascript Library]].&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:90%; background-color:whitesmoke&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;odbgetmsg_old&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
; ODBGetMsg (pre August 2015)&lt;br /&gt;
See: [[AJAX#jgenmsg]]&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetMsg(n)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* n - number of midas messages to return&lt;br /&gt;
&lt;br /&gt;
Returns: array of strings, if n==1, as single string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 var data = ODBGetMsg(10);&lt;br /&gt;
 document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= ODBGenMsg =&lt;br /&gt;
Send a message to the MIDAS [[Message System]] or the [[Chat Page|Chat]]. &lt;br /&gt;
&lt;br /&gt;
The parameters of this command have been changed August 2015. See [[#odbgenmsg_old|below]] for older version.&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
&lt;br /&gt;
* function ODBGenMsg(type, facility, user, msg)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* type -  midas message type, numerical value of one of MT_ERROR, MT_INFO, MT_DEBUG, MT_USER, as defined in midas.h. &lt;br /&gt;
: i.e. 1 for MT_ERROR, 2 for MT_INFO etc.&lt;br /&gt;
* facility - facility can be &amp;quot;midas&amp;quot; for the MIDAS message system, or &amp;quot;chat&amp;quot; for the chat message system&lt;br /&gt;
* user -  name of the user who generated the message&lt;br /&gt;
: The user name ends up in the message file inside the [] section to tag each message with an associated user name.&lt;br /&gt;
* message - text written into midas messages&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 ODBGenerateMsg(2, midas, fred, &amp;quot;message text&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size:90%; background-color:whitesmoke&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;odbgenmsg_old&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
; ODBGenerateMsg  (pre August 2015)&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jgenmsg]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGenerateMsg(m)&lt;br /&gt;
&lt;br /&gt;
Arguments:&lt;br /&gt;
* m - text written into midas messages, must be URI-encoded.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ODBGenerateMsg(encodeURIComponent(&amp;quot;message text&amp;quot;));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ODBGetAlarms =&lt;br /&gt;
&lt;br /&gt;
See: [[AJAX#jalm]]&lt;br /&gt;
&lt;br /&gt;
Prototype:&lt;br /&gt;
* function ODBGetAlarms()&lt;br /&gt;
&lt;br /&gt;
Returns: array of strings&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var data = ODBGetAlarms();&lt;br /&gt;
document.getElementById(&amp;quot;foo&amp;quot;).innerHTML = data.join(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Custom]] [[Category:Javascript library]] [[Category:Ajax]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3574</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3574"/>
		<updated>2025-11-04T22:54:22Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [[2025 MIDAS Workshop]]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3573</id>
		<title>2025 MIDAS Workshop</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3573"/>
		<updated>2025-11-04T22:53:54Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
The agenda and posted presentation are on the [https://indico.psi.ch/event/17580/timetable/ Indico page for 2025 workshop].&lt;br /&gt;
&lt;br /&gt;
[https://triumfoffice365-my.sharepoint.com/:v:/g/personal/lindner_triumf_ca/EYDh_iPG8CpEqUvKFiNUYXsBin4pC53fgtiAmfvnQscC7Q?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&amp;amp;e=iey0zn Zoom recording of day 1]&lt;br /&gt;
&lt;br /&gt;
[https://triumfoffice365-my.sharepoint.com/:v:/g/personal/lindner_triumf_ca/ETKLMOgo5vVDrW6cvohWBDMBUmYNzMBg2BRZdRk1RJEqug?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&amp;amp;e=Pcy5lY Zoom recording of day 2]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3572</id>
		<title>2025 MIDAS Workshop</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3572"/>
		<updated>2025-11-04T22:52:08Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
The agenda and posted presentation are on the [https://indico.psi.ch/event/17580/timetable/ Indico page for 2025 workshop].&lt;br /&gt;
&lt;br /&gt;
[https://triumfoffice365-my.sharepoint.com/:v:/g/personal/lindner_triumf_ca/EYDh_iPG8CpEqUvKFiNUYXsBin4pC53fgtiAmfvnQscC7Q?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&amp;amp;e=iey0zn Zoom recording of day 1]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3571</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3571"/>
		<updated>2025-11-04T22:51:02Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [[2025 MIDAS Workshop]]&lt;br /&gt;
* [https://indico.psi.ch/event/17580/ 2025 MIDAS Workshop]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3567</id>
		<title>2025 MIDAS Workshop</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=2025_MIDAS_Workshop&amp;diff=3567"/>
		<updated>2025-09-24T20:43:02Z</updated>

		<summary type="html">&lt;p&gt;Lindner: Created page with &amp;quot;  The agenda and posted presentation are on the [https://indico.psi.ch/event/17580/timetable/ Indico page for 2025 workshop].&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
The agenda and posted presentation are on the [https://indico.psi.ch/event/17580/timetable/ Indico page for 2025 workshop].&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3566</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3566"/>
		<updated>2025-09-24T20:42:01Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [[2025 MIDAS Workshop]]&lt;br /&gt;
* [https://indico.psi.ch/event/17580/ 2025 MIDAS Workshop]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3561</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3561"/>
		<updated>2025-09-18T23:16:30Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [https://indico.psi.ch/event/17580/ 2025 MIDAS Workshop]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3560</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3560"/>
		<updated>2025-09-18T23:16:05Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [https://indico.psi.ch/event/17580/ [2025 MIDAS Workshop]]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Equipment_Page&amp;diff=3511</id>
		<title>Equipment Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Equipment_Page&amp;diff=3511"/>
		<updated>2025-04-29T17:55:55Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Configuring the equipment page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
{{mhttpdpages}}&lt;br /&gt;
&lt;br /&gt;
= Purpose =&lt;br /&gt;
The purpose of the [[mhttpd]] equipment pages is to allow the user to view any Variables related to an equipment. &lt;br /&gt;
&lt;br /&gt;
= Access the equipment page =&lt;br /&gt;
&lt;br /&gt;
The main [[Status Page]] contains a list of all the equipment in an experiment (with each equipment being defined by a frontend). The name of each equipment on that page is a link to the relevant equipment page.&lt;br /&gt;
&lt;br /&gt;
= Configuring the equipment page =&lt;br /&gt;
&lt;br /&gt;
There are several ODB keys that can be defined in {{Odbpath|path=/Equipment/&amp;lt;equip_name&amp;gt;/}} that affect the behaviour of this webpage. See [[/Equipment_ODB_tree#Settings_subtree|the Equipment ODB tree]] documentation for full details, but in brief:&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Variables/&amp;quot; contains the Variables to show on this page (and to record in the history system).&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Names&amp;quot; or &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Names &amp;lt;variable&amp;gt;&amp;quot; contains the name of each element in the Variables arrays (e.g. channel names if recording the current of multiple channels).&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Unit &amp;lt;variable&amp;gt;&amp;quot; contains the units in which a variable is measured.&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Editable&amp;quot; contains a comma-separated list of variables that can be edited on the Equipment page.&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Grid display&amp;quot; is a boolean which allows you to switch between linear display and &amp;quot;grid&amp;quot; display.  These options are:&lt;br /&gt;
** Grid display: This is useful if there are “channels” with different attributes. Such as HV channels with current and voltage. In this case, we have several array under “Variables” which “belong” together, such as a voltage array and a current array. In this case one should have /Equpiment/&amp;lt;name&amp;gt;/Settings/Grid display = true, which cases the display like at the top of this page (Output on, Power good, Fault, Current). One also should then add “Names” under settings to have proper labels for each channel.  &lt;br /&gt;
** Non-grid display: Here we have arrays not related to each other. Here the grid display should be off, then you get the display directly above, where all banks are shown below each other.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All the settings are optional, and must be created by the user if desired.&lt;br /&gt;
&lt;br /&gt;
= Example configuration and display =&lt;br /&gt;
&lt;br /&gt;
Click to enlarge each image...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery widths=&amp;quot;300px&amp;quot; mode=&amp;quot;packed&amp;quot;&amp;gt;&lt;br /&gt;
Equipment_Variables.png|Variables&lt;br /&gt;
Equipment_Settings.png|Settings&lt;br /&gt;
Equipment_Page.png|Resulting display&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Equipment_Page&amp;diff=3510</id>
		<title>Equipment Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Equipment_Page&amp;diff=3510"/>
		<updated>2025-04-29T17:54:44Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Configuring the equipment page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
{{mhttpdpages}}&lt;br /&gt;
&lt;br /&gt;
= Purpose =&lt;br /&gt;
The purpose of the [[mhttpd]] equipment pages is to allow the user to view any Variables related to an equipment. &lt;br /&gt;
&lt;br /&gt;
= Access the equipment page =&lt;br /&gt;
&lt;br /&gt;
The main [[Status Page]] contains a list of all the equipment in an experiment (with each equipment being defined by a frontend). The name of each equipment on that page is a link to the relevant equipment page.&lt;br /&gt;
&lt;br /&gt;
= Configuring the equipment page =&lt;br /&gt;
&lt;br /&gt;
There are several ODB keys that can be defined in {{Odbpath|path=/Equipment/&amp;lt;equip_name&amp;gt;/}} that affect the behaviour of this webpage. See [[/Equipment_ODB_tree#Settings_subtree|the Equipment ODB tree]] documentation for full details, but in brief:&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Variables/&amp;quot; contains the Variables to show on this page (and to record in the history system).&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Names&amp;quot; or &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Names &amp;lt;variable&amp;gt;&amp;quot; contains the name of each element in the Variables arrays (e.g. channel names if recording the current of multiple channels).&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Unit &amp;lt;variable&amp;gt;&amp;quot; contains the units in which a variable is measured.&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Editable&amp;quot; contains a comma-separated list of variables that can be edited on the Equipment page.&lt;br /&gt;
* &amp;quot;/Equipment/&amp;lt;equip_name&amp;gt;/Settings/Grid display&amp;quot; is a boolean which allows you to switch between linear display and &amp;quot;grid&amp;quot; display.  These options are:&lt;br /&gt;
** Grid display: This is useful if there are “channels” with different attributes. Such as HV channels with current and voltage. In this case, we have several array under “Variables” which “belong” together, such as a voltage array and a current array. In this case one should have /Equpiment/&amp;lt;name&amp;gt;/Settings/Grid display = true, which cases the display like at the top of this page (Output on, Power good, Fault, Current). One also should then add “Names” under settings to have proper labels for each channel.&lt;br /&gt;
** Non-grid display: Here we have arrays not related to each other. Here the grid display should be off, then you get the display directly above, where all banks are shown below each other.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All the settings are optional, and must be created by the user if desired.&lt;br /&gt;
&lt;br /&gt;
= Example configuration and display =&lt;br /&gt;
&lt;br /&gt;
Click to enlarge each image...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery widths=&amp;quot;300px&amp;quot; mode=&amp;quot;packed&amp;quot;&amp;gt;&lt;br /&gt;
Equipment_Variables.png|Variables&lt;br /&gt;
Equipment_Settings.png|Settings&lt;br /&gt;
Equipment_Page.png|Resulting display&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3509</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3509"/>
		<updated>2025-04-25T22:47:05Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL using mariadb on macbook */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate0&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate1&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvex&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvey&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;t5&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login directly to the MySQL database and make sure the data is actually being logged&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; select _i_time,fluxgate0 from myperiodicequipment_pydt where _i_time &amp;lt;1745620795;&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| _i_time    | fluxgate0 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| 1745620782 |   6.20209 |&lt;br /&gt;
| 1745620783 |    6.3519 |&lt;br /&gt;
| 1745620784 |    6.5677 |&lt;br /&gt;
| 1745620785 |   7.81413 |&lt;br /&gt;
| 1745620786 |   5.41127 |&lt;br /&gt;
| 1745620787 |   7.31112 |&lt;br /&gt;
| 1745620788 |   6.14285 |&lt;br /&gt;
| 1745620789 |   7.20425 |&lt;br /&gt;
| 1745620790 |    6.9303 |&lt;br /&gt;
| 1745620791 |   7.08178 |&lt;br /&gt;
| 1745620792 |   7.44422 |&lt;br /&gt;
| 1745620794 |   5.32677 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
12 rows in set (0.00 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart mhttpd and you will see the history plots starting to get data from MySQL database.&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3508</id>
		<title>History System</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3508"/>
		<updated>2025-04-25T22:46:53Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Write  MYSQL-history events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;&lt;br /&gt;
* [[/History ODB tree]]&lt;br /&gt;
* [[History Page]]&lt;br /&gt;
* [[Mhformat|MIDAS history file format]] &lt;br /&gt;
* [[Keys in the ODB /Logger tree|/Logger ODB tree]]&lt;br /&gt;
* [[Keys in the ODB /Logger/History subtree|/Logger/History subtree]]&lt;br /&gt;
* [[Image History]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;history file&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The history system is an add-on capability built into the MIDAS data logger [[mlogger]] to record useful information in parallel to the data logging.&lt;br /&gt;
This information is recorded with a time stamp and saved into a &#039;&#039;&#039;history file&#039;&#039;&#039;  (see [[#History drivers|History drivers]]) for later retrieval. One set of files is created per day containing all the requested history events. The history data may be displayed in graphical form using the [[mhttpd]] MIDAS webserver utility, giving the user an easy way of seeing how experimental variables have changed with time.&lt;br /&gt;
The history logging will be in action only if the MIDAS data logger is running, but it is not necessary to have any [[Keys in the ODB /Logger tree#/Logger/Channels subtree|data logging channel]] enabled.&lt;br /&gt;
&lt;br /&gt;
Since June 2020, it is possible to also use the midas history system to record images (png/jpeg etc) periodically, for example to later produce a timelapse from a webcam - see the [[Image History]] page for more details.&lt;br /&gt;
&lt;br /&gt;
= MidasHistoryInterface =&lt;br /&gt;
&lt;br /&gt;
The new history configuration defines history channels similar to logger channels. Each history channel creates a history interface class (class MidasHistoryInterface). The [[mlogger|data logger]] can use this interface to write data into the history, mhttpd, mhist &amp;amp; co can use this interface to read data from the history. The interface is defined in history.h&lt;br /&gt;
&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas/include/history.h&lt;br /&gt;
&lt;br /&gt;
= History drivers =&lt;br /&gt;
&lt;br /&gt;
Presently, the MIDAS distribution contains these drivers:&lt;br /&gt;
&lt;br /&gt;
; MIDAS-History &lt;br /&gt;
: this is the traditional history driver, with data stored in the .hst binary files. (format is documented here [[mhformat]], see also [[mhist]] and [[mhdump]])&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MIDAS subtree |&amp;quot;MIDAS&amp;quot;]]&#039;&#039;&#039; is set up to write MIDAS-history. &lt;br /&gt;
&lt;br /&gt;
; ODBC-History  &lt;br /&gt;
: stores history data in SQL database using the ODBC abstraction layer. See [[#MIDAS ODBC SQL History system|ODBC SQL History system]].&lt;br /&gt;
&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#ODBC subtree|&amp;quot;ODBC&amp;quot;]]&#039;&#039;&#039; is set up to write ODBC-history.&lt;br /&gt;
&lt;br /&gt;
; SQLITE-History &lt;br /&gt;
: stores data in SQL database as SQLITE3 .sqlite3 files. The SQL table format is similar to ODBC-history, performance is similar, no database server required.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#SQLITE subtree|&amp;quot;SQLITE&amp;quot;]]&#039;&#039;&#039; is set up to write SQLITE-history.&lt;br /&gt;
&lt;br /&gt;
; MYSQL-History&lt;br /&gt;
:&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MYSQL subtree|&amp;quot;MYSQL&amp;quot;]]&#039;&#039;&#039; is set up to write MYSQL-history.&lt;br /&gt;
&lt;br /&gt;
; FILE-History&lt;br /&gt;
: stores each variable in its own file, making it much easier to trace the history of a particular variable.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#FILE subtree|FILE]]&#039;&#039;&#039; is set up to write FILE-history.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More drivers can be easily added by the user (create history_xxx.cxx, add constructor to hs_get_history(), create the ODB subtree  &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/Logger/History/xxx/channel&amp;lt;/span&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
= Location of History Files =&lt;br /&gt;
;MIDAS-history &lt;br /&gt;
:By default, the traditional MIDAS-history is enabled, writing history files into the MIDAS data directory path given by the ODB key [[Keys in the ODB /Logger tree#Data dir|Data dir]].&lt;br /&gt;
:If history data is important, it is recommended to write it to a directory that is backed up or archived. (The MIDAS data directory is usually located on a scratch data disk without backups).&lt;br /&gt;
 &lt;br /&gt;
:The location of the MIDAS-history data files can be changed by use of the ODB Key [[Keys in the ODB /Logger tree#History dir|History dir]]. &lt;br /&gt;
&lt;br /&gt;
;ODBC-History&lt;br /&gt;
:The location of ODBC-History files is ...&lt;br /&gt;
&lt;br /&gt;
;SQLITE-History &lt;br /&gt;
:The location of SQLITE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]].&lt;br /&gt;
&lt;br /&gt;
;MYSQL-History&lt;br /&gt;
:The location of MYSQL-History files is ...&lt;br /&gt;
&lt;br /&gt;
;FILE-History&lt;br /&gt;
:The location of FILE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Types of History Events =&lt;br /&gt;
&lt;br /&gt;
There are two basic types of history events, which are defined in different ways:&lt;br /&gt;
&lt;br /&gt;
*    &amp;quot;[[#Frontend History Event|Frontend]]&amp;quot; (or &amp;quot;Equipment&amp;quot;) History event composed in the frontend. See [[#Frontend History Event|Frontend History Event]] for details.&lt;br /&gt;
*    &amp;quot;Virtual&amp;quot; (or &amp;quot;Links&amp;quot;) History event composed within the ODB under the  [[/History ODB tree#Links subtree|/History/Links subtree]]. See [[#Virtual History Event|Virtual History Event]] for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both these history event definitions take effect when the data logger gets a start run [[Run States and Transitions|transition]]. Any modifications made during the run are not applied until the start of the next run.&lt;br /&gt;
&lt;br /&gt;
== Virtual History Event ==&lt;br /&gt;
The history of any ODB variable can be recorded in a &amp;quot;virtual&amp;quot; history event by creating a link to that variable in the [[/History ODB tree#Links subtree|/History/Links subtree]]. This is used for ODB variables that are not in an Equipment.&lt;br /&gt;
&lt;br /&gt;
; To enable Virtual History Events&lt;br /&gt;
: Create links as desired in [[/History ODB tree#Links subtree|/History/Links subtree]].&lt;br /&gt;
&lt;br /&gt;
History events are created for each entry under ODB subdirectory {{Odbpath|path=/History/Links}}.  &lt;br /&gt;
&lt;br /&gt;
Two types of links are permitted:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; ODB key {{Odbpath|path=/history/links/aaa}} is a link to a subdirectory&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; db_watch() is setup to watch this subdirectory&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each subdirectory entry (1 tag per entry)&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; There is no possibility for naming array elements, so 1 tag per array, regardless of the number of elements.&amp;lt;/li&amp;gt; &amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;ODB key {{Odbpath|path=/history/links/bbb}}  is a subdirectory with links to ODB values&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db_watch is setup to watch each link target&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each link (1 tag per link)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tag name is the link name (NOT the target name). There is no possibility for naming array elements&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mixing links and subdirectories is not permitted.&lt;br /&gt;
&lt;br /&gt;
The update period of history events created for {{Odbpath|path=/history/links}} is controlled by entries in  {{Odbpath|path=/history/links periods}}. Numeric values of periods are same as for a [[#Frontend History Event|Frontend History event]]. Numeric value 0 disables the history for a particular event.&lt;br /&gt;
&lt;br /&gt;
See [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087] for more information. &lt;br /&gt;
&lt;br /&gt;
== Frontend History Event ==&lt;br /&gt;
&lt;br /&gt;
Each  [[Frontend Operation#Equipments and Events|Equipment]] has the capability to generate &amp;quot;history data&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
; To enable Frontend History Events &lt;br /&gt;
&lt;br /&gt;
: Set the [[/Equipment ODB tree#Log history|Log history]] ODB key of each equipment to be logged &#039;&#039;&#039;non-zero&#039;&#039;&#039;. (See [[Equipment List Parameters#Log History|Log History parameter]]). (You may need to restart the frontend.)&lt;br /&gt;
&lt;br /&gt;
This causes the event contents to be copied to the  ODB [[/Equipment ODB tree#Variables subtree|/Equipment/&#039;&#039;&amp;lt;equipment-name&amp;gt;&#039;&#039;/Variables subtree]] for the use of the History system. history events are created by parsing the content of  {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/variables}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For each equipment, history is controlled by the value of {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/common/period}} as follows:&lt;br /&gt;
* 0 = history disabled&lt;br /&gt;
* 1 = history is enabled&lt;br /&gt;
* &amp;gt;1 = history is enabled, throttled down&lt;br /&gt;
&lt;br /&gt;
The throttling is implemented in log_history()/watch_history() by this algorithm:&lt;br /&gt;
the very first history event is recorded, then all changed to the data are ignored until &amp;quot;period&amp;quot; seconds has elapsed. Then the next history event will be recorded, and following&lt;br /&gt;
changes will be ignored until &amp;quot;period&amp;quot; second elapses, and so forth. Period value &amp;quot;1&amp;quot; has special meaning - there is no throttling, all history events are logged. &lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
=== Sequence for frontend History Event ===&lt;br /&gt;
The main steps for the frontend History Event is as follows:&lt;br /&gt;
&lt;br /&gt;
* The user code in the frontend equipment Event Readout routines reads the data, placing it into a MIDAS data bank&lt;br /&gt;
* In mfe.c, if the key [[/Equipment ODB tree#Log history|Log history]] &amp;gt; 0 (i.e. the history system is enabled for this equipment), this data bank is written into ODB (by update_odb()).&lt;br /&gt;
* This ODB write triggers an ODB hot-link into mlogger&lt;br /&gt;
* The hot-link calls mlogger.c::log_history(), which calls hs_write() to write the data into the history file. The frequency of the history writes is specified by the number of seconds between writes stored in the ODB key [[/Equipment ODB tree#Log history|Log history]].&lt;br /&gt;
* history.c::hs_write() or history_odbc::hs_write_odbc() writes the data into a history file or into an SQL database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= How to Write History events =&lt;br /&gt;
*  Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
*  [[#Select the history driver|Select the history driver]]&lt;br /&gt;
*  Follow instructions below for selected driver:&lt;br /&gt;
** [[#Write MIDAS-History events|Write MIDAS-history events]]&lt;br /&gt;
** [[#Write ODBC-History events|Write ODBC-history events]]&lt;br /&gt;
** [[#Write SQLITE-History events|Write SQLITE-history events]]&lt;br /&gt;
** [[#Write MYSQL-History events|Write MYSQL-history events]]&lt;br /&gt;
** [[#Write FILE-History events|Write FILE-history events]]&lt;br /&gt;
&lt;br /&gt;
== Select the history driver ==&lt;br /&gt;
&lt;br /&gt;
* Select the  &#039;&#039;&#039;[[#History drivers|history driver]]&#039;&#039;&#039; and therefore the [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to use to write the MIDAS-history files. &lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Active|Active]] ODB key in the selected  [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to &amp;quot;y&amp;quot;. All other logging channels should be disabled.&lt;br /&gt;
* set  [[/History ODB tree#LoggerHistoryChannel|LoggerHistoryChannel]] ODB key to the selected [[#History drivers|History channel]].&lt;br /&gt;
&lt;br /&gt;
== Write MIDAS-History events   ==&lt;br /&gt;
* Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MIDAS&amp;quot;.&lt;br /&gt;
* Restart [[mhttpd]] and [[mlogger]], start the run.&lt;br /&gt;
&lt;br /&gt;
MIDAS-history files will be saved into the  [[#Location of History Files|MIDAS-history data directory]]. &lt;br /&gt;
&lt;br /&gt;
== Write ODBC-History events  ==&lt;br /&gt;
&lt;br /&gt;
See [[#MIDAS ODBC SQL History system|MIDAS ODBC SQL History system]].&lt;br /&gt;
* If necessary, [[#Set up a MySQL database|set up a MySQL database]].&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;ODBC&amp;quot;.&lt;br /&gt;
* Check ODB Key [[Keys in the ODB /Logger/History subtree#Writer_ODBC_DSN|Writer_ODBC_DSN]] is set to &amp;quot;history writer&amp;quot; and Key [[Keys in the ODB /Logger/History subtree#Reader_ODBC_DSN|Reader_ODBC_DSN]] is set to &amp;quot;history reader&amp;quot; (the default values)&lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Debug|Debug]] to 1 if desired&lt;br /&gt;
* restart [[mlogger]] in verbose mode (i.e. mlogger -v), and observe how it issues SQL commands to create the tables and columns corresponding to MIDAS-history events and tags.&lt;br /&gt;
* restart [[mhttpd]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&lt;br /&gt;
# [[mlogger]] is programmed to raise alarms if connection to SQL database is interrupted or if some events cannot be written into the database (i.e. data type mismatch, SQL syntax errors, etc). The traditional MIDAS-history never raised alarms because it &amp;quot;never failed&amp;quot; - other than from &amp;quot;disk full&amp;quot; errors, which are immediately obvious.&lt;br /&gt;
# With ODBC History enabled, [[mhttpd]] will only use history information from the SQL database to make history plots and to extract history variable names for the history plot editor. The ODB  {{Odbpath|path=/History}}  subtrees[[/History ODB tree#Tags subtree|Tags]] and [[/History ODB tree#Events subtree|Events]]  are not used.&lt;br /&gt;
# variable names presented to the user may change from MIDAS names to SQL names (use the history panel &amp;quot;Label&amp;quot; text fields to create permanent plot labels).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Write  SQLITE-history events  ==&lt;br /&gt;
 &lt;br /&gt;
No special configuration required. &lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Create a directory for storage of sqlite history files&lt;br /&gt;
* save its path in the ODB key  [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]&lt;br /&gt;
* restart [[mhttpd]] and [[mlogger]]&lt;br /&gt;
&lt;br /&gt;
In the history data directory (in [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]) you should see files with name &amp;quot;mh_xxx.sqlite3&amp;quot; corresponding to your equipment and variable names. &lt;br /&gt;
&lt;br /&gt;
== Write  MYSQL-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MYSQL&amp;quot;.&lt;br /&gt;
* Read the following instructions to [[setup MySQL database for MIDAS]]:&lt;br /&gt;
&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
== Write  FILE-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
* Assign directory path for saved files using the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= History Events =&lt;br /&gt;
The following information is derived from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
A &amp;quot;history event&amp;quot; is a history atomic unit of data. Associated with each history event is a timestamp (unix time),&lt;br /&gt;
a name (limited to NAME_LENGTH in the old history) and a list of history tags that describe the individual data&lt;br /&gt;
values inside the history event.&lt;br /&gt;
&lt;br /&gt;
When making history plots in [[mhttpd]] (see [[History Page]]) for each curve on the plot, one selects a history event (from the list&lt;br /&gt;
of currently active events, recently active events or the list of all events that ever existed), then from the list of tags&lt;br /&gt;
inside the history event one selects the particular variable that will be plotted.&lt;br /&gt;
&lt;br /&gt;
== Old MIDAS history events ==&lt;br /&gt;
In the old MIDAS history, all history events are written into one history file (.hst file + optional .def and .idx event definition and time index files&lt;br /&gt;
which can be/are regenerated automatically from the .hst file). History events are identified by 16-bit history event IDs, the persistent mapping&lt;br /&gt;
from history event names and the 16-bit history event IDs is stored in ODB subtree {{Odbpath|path=/History/Events}}. In addition the list of all known history event tags is&lt;br /&gt;
stored in ODB subtree {{Odbpath|path=/History/Tags}}. For per-equipment history, the 16-bit history event ID is the value of ODB key [[/Equipment ODB tree#Event ID|/Equipment/&amp;lt;equipment-name&amp;gt;/Common/Event ID]].&lt;br /&gt;
&lt;br /&gt;
== SQL history events ==&lt;br /&gt;
In the SQL history (MySQL, SQLITE, etc), each history event is an SQL table. The history event tags are the SQL table columns.&lt;br /&gt;
&lt;br /&gt;
== FILE history events ==&lt;br /&gt;
In the new FILE history, each history event is written into a separate file, tag definition are recorded in text format in the file header, history event&lt;br /&gt;
data is appended to the file in binary format (fixed record size). If the history event definition is changed, a new file will be started.&lt;br /&gt;
&lt;br /&gt;
= History Event Construction =&lt;br /&gt;
The [[mlogger]] creates [[#Frontend history event]]s in open_history() by parsing the ODB subtree {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables}}. Each ODB entry under the {{Odbpath|path=variables/}} subtree is referred to as a &amp;quot;variable&amp;quot;. Each variable can be a single ODB value, an array of ODB values, or a subdirectory (corresponding to TID_STRUCT structured data banks). As each variable is processed, one or more tags are created to describe it. &lt;br /&gt;
&lt;br /&gt;
Single ODB values will generally produce a single tag, while arrays can produce (depending whether the array is &amp;quot;[[#Named Arrays|Named]]&amp;quot; or not)&lt;br /&gt;
* multiple tags  - one per array element (&amp;quot;Named&amp;quot; array) or&lt;br /&gt;
* one single tag - describing the whole array  &lt;br /&gt;
 &lt;br /&gt;
The code can generate two types of history:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-equipment&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have the tags for all variables concatenated together into one single history event&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-variable&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have one history event defined for each variable. Inside could be one tag (for single odb values and unnamed array)  or multiple tags (for named arrays and structured data &lt;br /&gt;
banks).&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per-equipment history is the original MIDAS history implementation. Per-variable history was added to permit efficient data storage in SQL tables. Its initial implementation used 1 ODB hotlink for each variable and it was easy to exceed the maximum permitted number of ODB hotlinks (db_open_record()). To reduce consumption of hotlinks, db_watch() has been implemented and now per-variable history only uses 1 ODB hotlink per equipment.&lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: With db_watch, per-equipment history is no longer available. &#039;&#039;&#039;Per-variable history is the new default&#039;&#039;&#039; (and the only option).&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087]&lt;br /&gt;
&lt;br /&gt;
= Construction of history event tags =&lt;br /&gt;
Currently,&lt;br /&gt;
* single ODB values are treated as arrays of length &amp;quot;1&amp;quot;&lt;br /&gt;
* string ODB entries are not permitted&lt;br /&gt;
&lt;br /&gt;
History event tags are constructed in the [[mlogger]] add_equipment(). Presently there are some quirks with the generation of history event tags (see  [https://midas.triumf.ca/elog/Midas/1088]),&lt;br /&gt;
e.g. single odb values are treated as arrays of length &amp;quot;1&amp;quot; and  &amp;quot;string&amp;quot; ODB entries are not permitted.&lt;br /&gt;
&lt;br /&gt;
For variables of type TID_KEY (subdirectories, corresponding to TID_STRUCT structured banks), one tag is generated for each subdirectory entry. Tag names for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa/bbb}} will be &amp;quot;aaa_bbb&amp;quot; (with an underscore). Subdirectory entries of type TID_KEY and TID_LINK are currently not supported.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Named Arrays]]&amp;quot;, individual tags are generated for each array element. Tag names are taken from the &#039;&#039;Names&#039;&#039; array. For empty tag names (empty names array), tags are &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc (for {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}). &lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Single Names Arrays]]&amp;quot;, tag names have the variable name appended (with a space), for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and an empty names array, tags will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, etc. For a populated names array, the tags will be &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
For unnamed arrays and single odb variables (in ODB, single odb variables are arrays of length 1), a single tag is generated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Named Arrays ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Named Arrays&#039;&#039;&#039; have a &amp;quot;Names&amp;quot; entry in {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings}}.&lt;br /&gt;
&lt;br /&gt;
For example, to add names to {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}, create a string array {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names aaa}}. The names array should be at least as long as the corresponding data array. Individual entries in the names array can be left blank (tag names will be &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc). Duplicate tag names are not permitted.&lt;br /&gt;
&lt;br /&gt;
A single &amp;quot;Names&amp;quot; entry can be created to name all arrays in variables with the same names (&#039;&#039;&#039;&amp;quot;Single Names&amp;quot;&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Create {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names}} and arrays {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/bbb}} will have &lt;br /&gt;
history tags &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, &amp;quot;name0 bbb&amp;quot;, &amp;quot;name1 bbb&amp;quot;, etc. If &amp;quot;names&amp;quot; are left blank, tag names will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, &amp;quot;bbb_0 bbb&amp;quot;, &amp;quot;bbb_1 bbb&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
In the [[mhttpd]] web server [[History Page]] variables viewer, &amp;quot;single name&amp;quot; arrays are displayed in a 2D table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1088].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Historical note on MIDAS-History Tag names =&lt;br /&gt;
Tags are only used for MIDAS-history events. &lt;br /&gt;
&lt;br /&gt;
The mlogger/mhttpd implementation of &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; has proved troublesome and we are moving away from it.&lt;br /&gt;
&lt;br /&gt;
;During the transition period:&lt;br /&gt;
:   Implementations starting with Version 4435 of [[mlogger]] and [[mhttpd]] (i.e. &amp;quot;new&amp;quot; versions) will now work &#039;&#039;&#039;without&#039;&#039;&#039; &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt;. The history tags are read directly from the history files themselves. To run in this mode, set  ODB key [[/History ODB tree#DisableTags|/History/DisableTags]] to &amp;quot;y&amp;quot;. Existing [[/History ODB tree#Tags subtree|/History/Tags subtree]] will be automatically deleted.&lt;br /&gt;
&lt;br /&gt;
Two downsides to running like this are&lt;br /&gt;
* it is slower and tags become non-persistent&lt;br /&gt;
* if some frontends have not been running for a while, their variables may vanish from the history panel editor.&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
== New-style History Tags ==&lt;br /&gt;
For the above two reasons, using &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; is still recommended.  &lt;br /&gt;
However, the format of the tags is now changed to simplify management and reduce ODB size. &lt;br /&gt;
&lt;br /&gt;
; For NEW implementations&lt;br /&gt;
: the key [[/History ODB tree#CreateOldTags|CreateOldTags]] will not be present. &amp;quot;New-style&amp;quot; history tags will be created automatically in the [[/History ODB tree#Tags subtree|Tags subtree]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;If you have old-style tags&lt;br /&gt;
: [[mlogger]] will automatically convert the old tags to this new format (this is why you should make a backup of your ODB).&lt;br /&gt;
&lt;br /&gt;
** using &amp;quot;old&amp;quot; (i.e. pre Version 4435) mlogger with &amp;quot;new&amp;quot; mhttpd is OK: new mhttpd understands both formats of /History/Tags.&lt;br /&gt;
** using &amp;quot;old&amp;quot; mhttpd with &amp;quot;new&amp;quot; mlogger is OK provided the ODB key [[/History ODB tree#CreateOldTags|/History/CreateOldTags]] is set to &amp;quot;y&amp;quot; before starting mlogger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Old-style History Tags ==&lt;br /&gt;
Prior to versions 4435 of [[mlogger]] and [[mhttpd]], old-style history tags were generated.&lt;br /&gt;
See&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/F_History_logging.html&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= MIDAS ODBC SQL History system =&lt;br /&gt;
&lt;br /&gt;
This section describes the internal workings of the MIDAS SQL history system.&lt;br /&gt;
&lt;br /&gt;
The SQL history system implements the MIDAS history using a SQL database for data storage instead of flat binary files.&lt;br /&gt;
&lt;br /&gt;
The SQL history code lives in a separate files history.h and history_sql.cxx. The present implementation uses the ODBC API for accessing SQL databases. &lt;br /&gt;
MySQL is fully supported, Pgsql support is partially implemented, support for arbitrary ODBC drivers should be easy to add in history_sql and most SQL operations are done using an interface class.&lt;br /&gt;
&lt;br /&gt;
Preliminary testing with MySQL and PgSQL indicates that disk space requirements are the same for both storage mechanisms using flat binary files or either of the 2 SQL databases. All 3 tested storage mechanisms store the data uncompressed. (Observed gzip-1 compression ratios from CERN-ALPHA history files are 50% or better).&lt;br /&gt;
&lt;br /&gt;
Preliminary testing also indicates that MySQL database is &amp;quot;not too slow&amp;quot; for use by T2K/ND280 slow control system. Using MySQL, performance seems to improve somewhat compared to traditional MIDAS-history because each SQL table is stored into a separate file, compared to everything-in-one-file in traditional MIDAS-history.&lt;br /&gt;
&lt;br /&gt;
== Set up a MySQL database ==&lt;br /&gt;
&lt;br /&gt;
In order to setup a MySQL database, the following is needed:&lt;br /&gt;
&lt;br /&gt;
*    the server hostname and port number&lt;br /&gt;
*    database name&lt;br /&gt;
*    user name and password.&lt;br /&gt;
&lt;br /&gt;
It is recommended to create 3 different users:&lt;br /&gt;
&lt;br /&gt;
*    a &amp;quot;root&amp;quot; user with full priveleges,&lt;br /&gt;
*    a &amp;quot;reader&amp;quot; user with read-only priveleges&lt;br /&gt;
*    and a &amp;quot;writer&amp;quot; user with &amp;quot;insert, create table, and add column&amp;quot; priveleges (no permission to drop table, remove columns, etc)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
#Setup a MySQL database (RHEL/SL 5)&lt;br /&gt;
&lt;br /&gt;
 ssh root@localhost&lt;br /&gt;
 service mysqld start&lt;br /&gt;
 /usr/bin/mysql_secure_installation (enter current password for root: press &amp;lt;enter&amp;gt;, then accept  default answer &amp;quot;Y&amp;quot; to all questions)&lt;br /&gt;
 mysqladmin -p create history&lt;br /&gt;
 using mysql-administrator, create 2 users:&lt;br /&gt;
 history_writer, with database &amp;quot;history&amp;quot; schema privileges: select, insert, create, alter, index&lt;br /&gt;
 history_reader, with database &amp;quot;history&amp;quot; schema privileges: select&lt;br /&gt;
&lt;br /&gt;
#Setup $HOME/.odbc.ini file:&lt;br /&gt;
&lt;br /&gt;
 cat $HOME/.odbc.ini&lt;br /&gt;
 [history_writer]&lt;br /&gt;
 Description  = history_writer&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_writer&lt;br /&gt;
 Password     = ******&lt;br /&gt;
 [history_reader]&lt;br /&gt;
 Description  = history_reader&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_reader&lt;br /&gt;
 Password     =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: if you are using mhist you will need a separate .odbc.ini file for each user that you have connecting to the database (through MIDAS).&lt;br /&gt;
&lt;br /&gt;
== Layout of SQL tables ==&lt;br /&gt;
&lt;br /&gt;
* One table is created for each history event. Table name is the same as the history event name (as reported by [[mhdump]]).&lt;br /&gt;
* one column is created for each history tag (history variable). Column name is the same as the tag name (as reported by mhdump). For array tags, one column is created for each array element: array a[3] will produce columns a_0, a_1 and a_2.&lt;br /&gt;
* two special columns are always created: _i_time and _t_time are the timestamps in the UNIX-time integer format and in the SQL &amp;quot;time&amp;quot; format. (A priori, it is not clear which timestamp format is more useful for end users. mhttpd uses the _i_time integer time format). Note that this timestamp is the time when mlogger receives the hot-link signal (see above) and it can be a few seconds behind the time when the user placed the data into the MIDAS bank. For high precision (and sub-second time resolution) time stamps, users should generate their own timestamps and include them as part of the data itself.&lt;br /&gt;
* a special table called _history_index is created to remember the mapping between SQL names and MIDAS names for event names, variable name and tag names.&lt;br /&gt;
&lt;br /&gt;
=== Schema Evolution ===&lt;br /&gt;
&lt;br /&gt;
*    when new data fields are added, new SQL columns are created automatically&lt;br /&gt;
*    existing SQL columns are never deleted&lt;br /&gt;
*    arrays are expanded automatically, and arrays never shrink.&lt;br /&gt;
*    if the type of a data field changes, a conflict may occur with existing SQL columns, for example if previous type was &amp;quot;FLOAT&amp;quot; and new type is &amp;quot;DOUBLE&amp;quot;, the existing SQL columns would have the SQL data type &amp;quot;float&amp;quot;, too narrow to store new values. mlogger will complain about this. Such conflicts may be resolved by changing the type of the SQL column using SQL tools. In general, SQL names are created from MIDAS names by replacing all non-alphanumerical characters to an underscore &amp;quot;_&amp;quot;. If this procedure creates duplicate column names, the column names and made unique by appending them with a random number, i.e. MIDAS names &amp;quot;A+B&amp;quot; and &amp;quot;A-B&amp;quot; will be translated to &amp;quot;A_B&amp;quot; and &amp;quot;A_B_12345&amp;quot; (random integer). True MIDAS names are saved into the _history_index.&lt;br /&gt;
&lt;br /&gt;
[[Category:history]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3507</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3507"/>
		<updated>2025-04-25T22:45:44Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate0&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate1&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvex&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvey&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;t5&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login directly to the MySQL database and make sure the data is actually being logged&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; select _i_time,fluxgate0 from myperiodicequipment_pydt where _i_time &amp;lt;1745620795;&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| _i_time    | fluxgate0 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| 1745620782 |   6.20209 |&lt;br /&gt;
| 1745620783 |    6.3519 |&lt;br /&gt;
| 1745620784 |    6.5677 |&lt;br /&gt;
| 1745620785 |   7.81413 |&lt;br /&gt;
| 1745620786 |   5.41127 |&lt;br /&gt;
| 1745620787 |   7.31112 |&lt;br /&gt;
| 1745620788 |   6.14285 |&lt;br /&gt;
| 1745620789 |   7.20425 |&lt;br /&gt;
| 1745620790 |    6.9303 |&lt;br /&gt;
| 1745620791 |   7.08178 |&lt;br /&gt;
| 1745620792 |   7.44422 |&lt;br /&gt;
| 1745620794 |   5.32677 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
12 rows in set (0.00 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart mhttpd and you will see the history plots starting to get data from MySQL database.&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3506</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3506"/>
		<updated>2025-04-25T22:44:39Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate0&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate1&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvex&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvey&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;t5&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login directly to the MySQL database and make sure the data is actually being logged&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; select _i_time,fluxgate0 from myperiodicequipment_pydt where _i_time &amp;lt;1745620795;&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| _i_time    | fluxgate0 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| 1745620782 |   6.20209 |&lt;br /&gt;
| 1745620783 |    6.3519 |&lt;br /&gt;
| 1745620784 |    6.5677 |&lt;br /&gt;
| 1745620785 |   7.81413 |&lt;br /&gt;
| 1745620786 |   5.41127 |&lt;br /&gt;
| 1745620787 |   7.31112 |&lt;br /&gt;
| 1745620788 |   6.14285 |&lt;br /&gt;
| 1745620789 |   7.20425 |&lt;br /&gt;
| 1745620790 |    6.9303 |&lt;br /&gt;
| 1745620791 |   7.08178 |&lt;br /&gt;
| 1745620792 |   7.44422 |&lt;br /&gt;
| 1745620794 |   5.32677 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
12 rows in set (0.00 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3505</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3505"/>
		<updated>2025-04-25T22:41:58Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate0&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate1&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvex&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvey&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;t5&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3504</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3504"/>
		<updated>2025-04-25T22:40:43Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;tag_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;tag_type&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3503</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3503"/>
		<updated>2025-04-25T22:34:04Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3502</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3502"/>
		<updated>2025-04-25T22:33:37Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as the experiment user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_PsFtKL5kR3&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_MQgoHDLqN3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3501</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3501"/>
		<updated>2025-04-25T22:24:43Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as root user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3500</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3500"/>
		<updated>2025-04-25T22:23:36Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Do these steps as root user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3499</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3499"/>
		<updated>2025-04-25T22:19:59Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3498</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3498"/>
		<updated>2025-04-25T22:18:34Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
Do these steps as root user.&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do these steps as the experiment user&lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3497</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3497"/>
		<updated>2025-04-25T22:16:03Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3496</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3496"/>
		<updated>2025-04-25T22:13:56Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3492</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3492"/>
		<updated>2025-04-23T21:32:46Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3491</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3491"/>
		<updated>2025-04-23T21:29:49Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3490</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3490"/>
		<updated>2025-04-23T21:28:07Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Setting up MySQL using mariadb on macbook */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS == &lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3489</id>
		<title>History System</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3489"/>
		<updated>2025-04-23T21:27:43Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Write  MYSQL-history events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;&lt;br /&gt;
* [[/History ODB tree]]&lt;br /&gt;
* [[History Page]]&lt;br /&gt;
* [[Mhformat|MIDAS history file format]] &lt;br /&gt;
* [[Keys in the ODB /Logger tree|/Logger ODB tree]]&lt;br /&gt;
* [[Keys in the ODB /Logger/History subtree|/Logger/History subtree]]&lt;br /&gt;
* [[Image History]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;history file&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The history system is an add-on capability built into the MIDAS data logger [[mlogger]] to record useful information in parallel to the data logging.&lt;br /&gt;
This information is recorded with a time stamp and saved into a &#039;&#039;&#039;history file&#039;&#039;&#039;  (see [[#History drivers|History drivers]]) for later retrieval. One set of files is created per day containing all the requested history events. The history data may be displayed in graphical form using the [[mhttpd]] MIDAS webserver utility, giving the user an easy way of seeing how experimental variables have changed with time.&lt;br /&gt;
The history logging will be in action only if the MIDAS data logger is running, but it is not necessary to have any [[Keys in the ODB /Logger tree#/Logger/Channels subtree|data logging channel]] enabled.&lt;br /&gt;
&lt;br /&gt;
Since June 2020, it is possible to also use the midas history system to record images (png/jpeg etc) periodically, for example to later produce a timelapse from a webcam - see the [[Image History]] page for more details.&lt;br /&gt;
&lt;br /&gt;
= MidasHistoryInterface =&lt;br /&gt;
&lt;br /&gt;
The new history configuration defines history channels similar to logger channels. Each history channel creates a history interface class (class MidasHistoryInterface). The [[mlogger|data logger]] can use this interface to write data into the history, mhttpd, mhist &amp;amp; co can use this interface to read data from the history. The interface is defined in history.h&lt;br /&gt;
&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas/include/history.h&lt;br /&gt;
&lt;br /&gt;
= History drivers =&lt;br /&gt;
&lt;br /&gt;
Presently, the MIDAS distribution contains these drivers:&lt;br /&gt;
&lt;br /&gt;
; MIDAS-History &lt;br /&gt;
: this is the traditional history driver, with data stored in the .hst binary files. (format is documented here [[mhformat]], see also [[mhist]] and [[mhdump]])&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MIDAS subtree |&amp;quot;MIDAS&amp;quot;]]&#039;&#039;&#039; is set up to write MIDAS-history. &lt;br /&gt;
&lt;br /&gt;
; ODBC-History  &lt;br /&gt;
: stores history data in SQL database using the ODBC abstraction layer. See [[#MIDAS ODBC SQL History system|ODBC SQL History system]].&lt;br /&gt;
&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#ODBC subtree|&amp;quot;ODBC&amp;quot;]]&#039;&#039;&#039; is set up to write ODBC-history.&lt;br /&gt;
&lt;br /&gt;
; SQLITE-History &lt;br /&gt;
: stores data in SQL database as SQLITE3 .sqlite3 files. The SQL table format is similar to ODBC-history, performance is similar, no database server required.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#SQLITE subtree|&amp;quot;SQLITE&amp;quot;]]&#039;&#039;&#039; is set up to write SQLITE-history.&lt;br /&gt;
&lt;br /&gt;
; MYSQL-History&lt;br /&gt;
:&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MYSQL subtree|&amp;quot;MYSQL&amp;quot;]]&#039;&#039;&#039; is set up to write MYSQL-history.&lt;br /&gt;
&lt;br /&gt;
; FILE-History&lt;br /&gt;
: stores each variable in its own file, making it much easier to trace the history of a particular variable.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#FILE subtree|FILE]]&#039;&#039;&#039; is set up to write FILE-history.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More drivers can be easily added by the user (create history_xxx.cxx, add constructor to hs_get_history(), create the ODB subtree  &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/Logger/History/xxx/channel&amp;lt;/span&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
= Location of History Files =&lt;br /&gt;
;MIDAS-history &lt;br /&gt;
:By default, the traditional MIDAS-history is enabled, writing history files into the MIDAS data directory path given by the ODB key [[Keys in the ODB /Logger tree#Data dir|Data dir]].&lt;br /&gt;
:If history data is important, it is recommended to write it to a directory that is backed up or archived. (The MIDAS data directory is usually located on a scratch data disk without backups).&lt;br /&gt;
 &lt;br /&gt;
:The location of the MIDAS-history data files can be changed by use of the ODB Key [[Keys in the ODB /Logger tree#History dir|History dir]]. &lt;br /&gt;
&lt;br /&gt;
;ODBC-History&lt;br /&gt;
:The location of ODBC-History files is ...&lt;br /&gt;
&lt;br /&gt;
;SQLITE-History &lt;br /&gt;
:The location of SQLITE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]].&lt;br /&gt;
&lt;br /&gt;
;MYSQL-History&lt;br /&gt;
:The location of MYSQL-History files is ...&lt;br /&gt;
&lt;br /&gt;
;FILE-History&lt;br /&gt;
:The location of FILE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Types of History Events =&lt;br /&gt;
&lt;br /&gt;
There are two basic types of history events, which are defined in different ways:&lt;br /&gt;
&lt;br /&gt;
*    &amp;quot;[[#Frontend History Event|Frontend]]&amp;quot; (or &amp;quot;Equipment&amp;quot;) History event composed in the frontend. See [[#Frontend History Event|Frontend History Event]] for details.&lt;br /&gt;
*    &amp;quot;Virtual&amp;quot; (or &amp;quot;Links&amp;quot;) History event composed within the ODB under the  [[/History ODB tree#Links subtree|/History/Links subtree]]. See [[#Virtual History Event|Virtual History Event]] for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both these history event definitions take effect when the data logger gets a start run [[Run States and Transitions|transition]]. Any modifications made during the run are not applied until the start of the next run.&lt;br /&gt;
&lt;br /&gt;
== Virtual History Event ==&lt;br /&gt;
The history of any ODB variable can be recorded in a &amp;quot;virtual&amp;quot; history event by creating a link to that variable in the [[/History ODB tree#Links subtree|/History/Links subtree]]. This is used for ODB variables that are not in an Equipment.&lt;br /&gt;
&lt;br /&gt;
; To enable Virtual History Events&lt;br /&gt;
: Create links as desired in [[/History ODB tree#Links subtree|/History/Links subtree]].&lt;br /&gt;
&lt;br /&gt;
History events are created for each entry under ODB subdirectory {{Odbpath|path=/History/Links}}.  &lt;br /&gt;
&lt;br /&gt;
Two types of links are permitted:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; ODB key {{Odbpath|path=/history/links/aaa}} is a link to a subdirectory&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; db_watch() is setup to watch this subdirectory&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each subdirectory entry (1 tag per entry)&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; There is no possibility for naming array elements, so 1 tag per array, regardless of the number of elements.&amp;lt;/li&amp;gt; &amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;ODB key {{Odbpath|path=/history/links/bbb}}  is a subdirectory with links to ODB values&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db_watch is setup to watch each link target&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each link (1 tag per link)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tag name is the link name (NOT the target name). There is no possibility for naming array elements&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mixing links and subdirectories is not permitted.&lt;br /&gt;
&lt;br /&gt;
The update period of history events created for {{Odbpath|path=/history/links}} is controlled by entries in  {{Odbpath|path=/history/links periods}}. Numeric values of periods are same as for a [[#Frontend History Event|Frontend History event]]. Numeric value 0 disables the history for a particular event.&lt;br /&gt;
&lt;br /&gt;
See [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087] for more information. &lt;br /&gt;
&lt;br /&gt;
== Frontend History Event ==&lt;br /&gt;
&lt;br /&gt;
Each  [[Frontend Operation#Equipments and Events|Equipment]] has the capability to generate &amp;quot;history data&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
; To enable Frontend History Events &lt;br /&gt;
&lt;br /&gt;
: Set the [[/Equipment ODB tree#Log history|Log history]] ODB key of each equipment to be logged &#039;&#039;&#039;non-zero&#039;&#039;&#039;. (See [[Equipment List Parameters#Log History|Log History parameter]]). (You may need to restart the frontend.)&lt;br /&gt;
&lt;br /&gt;
This causes the event contents to be copied to the  ODB [[/Equipment ODB tree#Variables subtree|/Equipment/&#039;&#039;&amp;lt;equipment-name&amp;gt;&#039;&#039;/Variables subtree]] for the use of the History system. history events are created by parsing the content of  {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/variables}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For each equipment, history is controlled by the value of {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/common/period}} as follows:&lt;br /&gt;
* 0 = history disabled&lt;br /&gt;
* 1 = history is enabled&lt;br /&gt;
* &amp;gt;1 = history is enabled, throttled down&lt;br /&gt;
&lt;br /&gt;
The throttling is implemented in log_history()/watch_history() by this algorithm:&lt;br /&gt;
the very first history event is recorded, then all changed to the data are ignored until &amp;quot;period&amp;quot; seconds has elapsed. Then the next history event will be recorded, and following&lt;br /&gt;
changes will be ignored until &amp;quot;period&amp;quot; second elapses, and so forth. Period value &amp;quot;1&amp;quot; has special meaning - there is no throttling, all history events are logged. &lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
=== Sequence for frontend History Event ===&lt;br /&gt;
The main steps for the frontend History Event is as follows:&lt;br /&gt;
&lt;br /&gt;
* The user code in the frontend equipment Event Readout routines reads the data, placing it into a MIDAS data bank&lt;br /&gt;
* In mfe.c, if the key [[/Equipment ODB tree#Log history|Log history]] &amp;gt; 0 (i.e. the history system is enabled for this equipment), this data bank is written into ODB (by update_odb()).&lt;br /&gt;
* This ODB write triggers an ODB hot-link into mlogger&lt;br /&gt;
* The hot-link calls mlogger.c::log_history(), which calls hs_write() to write the data into the history file. The frequency of the history writes is specified by the number of seconds between writes stored in the ODB key [[/Equipment ODB tree#Log history|Log history]].&lt;br /&gt;
* history.c::hs_write() or history_odbc::hs_write_odbc() writes the data into a history file or into an SQL database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= How to Write History events =&lt;br /&gt;
*  Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
*  [[#Select the history driver|Select the history driver]]&lt;br /&gt;
*  Follow instructions below for selected driver:&lt;br /&gt;
** [[#Write MIDAS-History events|Write MIDAS-history events]]&lt;br /&gt;
** [[#Write ODBC-History events|Write ODBC-history events]]&lt;br /&gt;
** [[#Write SQLITE-History events|Write SQLITE-history events]]&lt;br /&gt;
** [[#Write MYSQL-History events|Write MYSQL-history events]]&lt;br /&gt;
** [[#Write FILE-History events|Write FILE-history events]]&lt;br /&gt;
&lt;br /&gt;
== Select the history driver ==&lt;br /&gt;
&lt;br /&gt;
* Select the  &#039;&#039;&#039;[[#History drivers|history driver]]&#039;&#039;&#039; and therefore the [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to use to write the MIDAS-history files. &lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Active|Active]] ODB key in the selected  [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to &amp;quot;y&amp;quot;. All other logging channels should be disabled.&lt;br /&gt;
* set  [[/History ODB tree#LoggerHistoryChannel|LoggerHistoryChannel]] ODB key to the selected [[#History drivers|History channel]].&lt;br /&gt;
&lt;br /&gt;
== Write MIDAS-History events   ==&lt;br /&gt;
* Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MIDAS&amp;quot;.&lt;br /&gt;
* Restart [[mhttpd]] and [[mlogger]], start the run.&lt;br /&gt;
&lt;br /&gt;
MIDAS-history files will be saved into the  [[#Location of History Files|MIDAS-history data directory]]. &lt;br /&gt;
&lt;br /&gt;
== Write ODBC-History events  ==&lt;br /&gt;
&lt;br /&gt;
See [[#MIDAS ODBC SQL History system|MIDAS ODBC SQL History system]].&lt;br /&gt;
* If necessary, [[#Set up a MySQL database|set up a MySQL database]].&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;ODBC&amp;quot;.&lt;br /&gt;
* Check ODB Key [[Keys in the ODB /Logger/History subtree#Writer_ODBC_DSN|Writer_ODBC_DSN]] is set to &amp;quot;history writer&amp;quot; and Key [[Keys in the ODB /Logger/History subtree#Reader_ODBC_DSN|Reader_ODBC_DSN]] is set to &amp;quot;history reader&amp;quot; (the default values)&lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Debug|Debug]] to 1 if desired&lt;br /&gt;
* restart [[mlogger]] in verbose mode (i.e. mlogger -v), and observe how it issues SQL commands to create the tables and columns corresponding to MIDAS-history events and tags.&lt;br /&gt;
* restart [[mhttpd]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&lt;br /&gt;
# [[mlogger]] is programmed to raise alarms if connection to SQL database is interrupted or if some events cannot be written into the database (i.e. data type mismatch, SQL syntax errors, etc). The traditional MIDAS-history never raised alarms because it &amp;quot;never failed&amp;quot; - other than from &amp;quot;disk full&amp;quot; errors, which are immediately obvious.&lt;br /&gt;
# With ODBC History enabled, [[mhttpd]] will only use history information from the SQL database to make history plots and to extract history variable names for the history plot editor. The ODB  {{Odbpath|path=/History}}  subtrees[[/History ODB tree#Tags subtree|Tags]] and [[/History ODB tree#Events subtree|Events]]  are not used.&lt;br /&gt;
# variable names presented to the user may change from MIDAS names to SQL names (use the history panel &amp;quot;Label&amp;quot; text fields to create permanent plot labels).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Write  SQLITE-history events  ==&lt;br /&gt;
 &lt;br /&gt;
No special configuration required. &lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Create a directory for storage of sqlite history files&lt;br /&gt;
* save its path in the ODB key  [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]&lt;br /&gt;
* restart [[mhttpd]] and [[mlogger]]&lt;br /&gt;
&lt;br /&gt;
In the history data directory (in [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]) you should see files with name &amp;quot;mh_xxx.sqlite3&amp;quot; corresponding to your equipment and variable names. &lt;br /&gt;
&lt;br /&gt;
== Write  MYSQL-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MYSQL&amp;quot;.&lt;br /&gt;
* Read the following instructions to [[setup MySQL database for MIDAS]]:&lt;br /&gt;
&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
== Write  FILE-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
* Assign directory path for saved files using the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= History Events =&lt;br /&gt;
The following information is derived from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
A &amp;quot;history event&amp;quot; is a history atomic unit of data. Associated with each history event is a timestamp (unix time),&lt;br /&gt;
a name (limited to NAME_LENGTH in the old history) and a list of history tags that describe the individual data&lt;br /&gt;
values inside the history event.&lt;br /&gt;
&lt;br /&gt;
When making history plots in [[mhttpd]] (see [[History Page]]) for each curve on the plot, one selects a history event (from the list&lt;br /&gt;
of currently active events, recently active events or the list of all events that ever existed), then from the list of tags&lt;br /&gt;
inside the history event one selects the particular variable that will be plotted.&lt;br /&gt;
&lt;br /&gt;
== Old MIDAS history events ==&lt;br /&gt;
In the old MIDAS history, all history events are written into one history file (.hst file + optional .def and .idx event definition and time index files&lt;br /&gt;
which can be/are regenerated automatically from the .hst file). History events are identified by 16-bit history event IDs, the persistent mapping&lt;br /&gt;
from history event names and the 16-bit history event IDs is stored in ODB subtree {{Odbpath|path=/History/Events}}. In addition the list of all known history event tags is&lt;br /&gt;
stored in ODB subtree {{Odbpath|path=/History/Tags}}. For per-equipment history, the 16-bit history event ID is the value of ODB key [[/Equipment ODB tree#Event ID|/Equipment/&amp;lt;equipment-name&amp;gt;/Common/Event ID]].&lt;br /&gt;
&lt;br /&gt;
== SQL history events ==&lt;br /&gt;
In the SQL history (MySQL, SQLITE, etc), each history event is an SQL table. The history event tags are the SQL table columns.&lt;br /&gt;
&lt;br /&gt;
== FILE history events ==&lt;br /&gt;
In the new FILE history, each history event is written into a separate file, tag definition are recorded in text format in the file header, history event&lt;br /&gt;
data is appended to the file in binary format (fixed record size). If the history event definition is changed, a new file will be started.&lt;br /&gt;
&lt;br /&gt;
= History Event Construction =&lt;br /&gt;
The [[mlogger]] creates [[#Frontend history event]]s in open_history() by parsing the ODB subtree {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables}}. Each ODB entry under the {{Odbpath|path=variables/}} subtree is referred to as a &amp;quot;variable&amp;quot;. Each variable can be a single ODB value, an array of ODB values, or a subdirectory (corresponding to TID_STRUCT structured data banks). As each variable is processed, one or more tags are created to describe it. &lt;br /&gt;
&lt;br /&gt;
Single ODB values will generally produce a single tag, while arrays can produce (depending whether the array is &amp;quot;[[#Named Arrays|Named]]&amp;quot; or not)&lt;br /&gt;
* multiple tags  - one per array element (&amp;quot;Named&amp;quot; array) or&lt;br /&gt;
* one single tag - describing the whole array  &lt;br /&gt;
 &lt;br /&gt;
The code can generate two types of history:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-equipment&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have the tags for all variables concatenated together into one single history event&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-variable&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have one history event defined for each variable. Inside could be one tag (for single odb values and unnamed array)  or multiple tags (for named arrays and structured data &lt;br /&gt;
banks).&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per-equipment history is the original MIDAS history implementation. Per-variable history was added to permit efficient data storage in SQL tables. Its initial implementation used 1 ODB hotlink for each variable and it was easy to exceed the maximum permitted number of ODB hotlinks (db_open_record()). To reduce consumption of hotlinks, db_watch() has been implemented and now per-variable history only uses 1 ODB hotlink per equipment.&lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: With db_watch, per-equipment history is no longer available. &#039;&#039;&#039;Per-variable history is the new default&#039;&#039;&#039; (and the only option).&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087]&lt;br /&gt;
&lt;br /&gt;
= Construction of history event tags =&lt;br /&gt;
Currently,&lt;br /&gt;
* single ODB values are treated as arrays of length &amp;quot;1&amp;quot;&lt;br /&gt;
* string ODB entries are not permitted&lt;br /&gt;
&lt;br /&gt;
History event tags are constructed in the [[mlogger]] add_equipment(). Presently there are some quirks with the generation of history event tags (see  [https://midas.triumf.ca/elog/Midas/1088]),&lt;br /&gt;
e.g. single odb values are treated as arrays of length &amp;quot;1&amp;quot; and  &amp;quot;string&amp;quot; ODB entries are not permitted.&lt;br /&gt;
&lt;br /&gt;
For variables of type TID_KEY (subdirectories, corresponding to TID_STRUCT structured banks), one tag is generated for each subdirectory entry. Tag names for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa/bbb}} will be &amp;quot;aaa_bbb&amp;quot; (with an underscore). Subdirectory entries of type TID_KEY and TID_LINK are currently not supported.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Named Arrays]]&amp;quot;, individual tags are generated for each array element. Tag names are taken from the &#039;&#039;Names&#039;&#039; array. For empty tag names (empty names array), tags are &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc (for {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}). &lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Single Names Arrays]]&amp;quot;, tag names have the variable name appended (with a space), for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and an empty names array, tags will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, etc. For a populated names array, the tags will be &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
For unnamed arrays and single odb variables (in ODB, single odb variables are arrays of length 1), a single tag is generated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Named Arrays ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Named Arrays&#039;&#039;&#039; have a &amp;quot;Names&amp;quot; entry in {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings}}.&lt;br /&gt;
&lt;br /&gt;
For example, to add names to {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}, create a string array {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names aaa}}. The names array should be at least as long as the corresponding data array. Individual entries in the names array can be left blank (tag names will be &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc). Duplicate tag names are not permitted.&lt;br /&gt;
&lt;br /&gt;
A single &amp;quot;Names&amp;quot; entry can be created to name all arrays in variables with the same names (&#039;&#039;&#039;&amp;quot;Single Names&amp;quot;&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Create {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names}} and arrays {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/bbb}} will have &lt;br /&gt;
history tags &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, &amp;quot;name0 bbb&amp;quot;, &amp;quot;name1 bbb&amp;quot;, etc. If &amp;quot;names&amp;quot; are left blank, tag names will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, &amp;quot;bbb_0 bbb&amp;quot;, &amp;quot;bbb_1 bbb&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
In the [[mhttpd]] web server [[History Page]] variables viewer, &amp;quot;single name&amp;quot; arrays are displayed in a 2D table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1088].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Historical note on MIDAS-History Tag names =&lt;br /&gt;
Tags are only used for MIDAS-history events. &lt;br /&gt;
&lt;br /&gt;
The mlogger/mhttpd implementation of &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; has proved troublesome and we are moving away from it.&lt;br /&gt;
&lt;br /&gt;
;During the transition period:&lt;br /&gt;
:   Implementations starting with Version 4435 of [[mlogger]] and [[mhttpd]] (i.e. &amp;quot;new&amp;quot; versions) will now work &#039;&#039;&#039;without&#039;&#039;&#039; &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt;. The history tags are read directly from the history files themselves. To run in this mode, set  ODB key [[/History ODB tree#DisableTags|/History/DisableTags]] to &amp;quot;y&amp;quot;. Existing [[/History ODB tree#Tags subtree|/History/Tags subtree]] will be automatically deleted.&lt;br /&gt;
&lt;br /&gt;
Two downsides to running like this are&lt;br /&gt;
* it is slower and tags become non-persistent&lt;br /&gt;
* if some frontends have not been running for a while, their variables may vanish from the history panel editor.&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
== New-style History Tags ==&lt;br /&gt;
For the above two reasons, using &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; is still recommended.  &lt;br /&gt;
However, the format of the tags is now changed to simplify management and reduce ODB size. &lt;br /&gt;
&lt;br /&gt;
; For NEW implementations&lt;br /&gt;
: the key [[/History ODB tree#CreateOldTags|CreateOldTags]] will not be present. &amp;quot;New-style&amp;quot; history tags will be created automatically in the [[/History ODB tree#Tags subtree|Tags subtree]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;If you have old-style tags&lt;br /&gt;
: [[mlogger]] will automatically convert the old tags to this new format (this is why you should make a backup of your ODB).&lt;br /&gt;
&lt;br /&gt;
** using &amp;quot;old&amp;quot; (i.e. pre Version 4435) mlogger with &amp;quot;new&amp;quot; mhttpd is OK: new mhttpd understands both formats of /History/Tags.&lt;br /&gt;
** using &amp;quot;old&amp;quot; mhttpd with &amp;quot;new&amp;quot; mlogger is OK provided the ODB key [[/History ODB tree#CreateOldTags|/History/CreateOldTags]] is set to &amp;quot;y&amp;quot; before starting mlogger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Old-style History Tags ==&lt;br /&gt;
Prior to versions 4435 of [[mlogger]] and [[mhttpd]], old-style history tags were generated.&lt;br /&gt;
See&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/F_History_logging.html&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= MIDAS ODBC SQL History system =&lt;br /&gt;
&lt;br /&gt;
This section describes the internal workings of the MIDAS SQL history system.&lt;br /&gt;
&lt;br /&gt;
The SQL history system implements the MIDAS history using a SQL database for data storage instead of flat binary files.&lt;br /&gt;
&lt;br /&gt;
The SQL history code lives in a separate files history.h and history_sql.cxx. The present implementation uses the ODBC API for accessing SQL databases. &lt;br /&gt;
MySQL is fully supported, Pgsql support is partially implemented, support for arbitrary ODBC drivers should be easy to add in history_sql and most SQL operations are done using an interface class.&lt;br /&gt;
&lt;br /&gt;
Preliminary testing with MySQL and PgSQL indicates that disk space requirements are the same for both storage mechanisms using flat binary files or either of the 2 SQL databases. All 3 tested storage mechanisms store the data uncompressed. (Observed gzip-1 compression ratios from CERN-ALPHA history files are 50% or better).&lt;br /&gt;
&lt;br /&gt;
Preliminary testing also indicates that MySQL database is &amp;quot;not too slow&amp;quot; for use by T2K/ND280 slow control system. Using MySQL, performance seems to improve somewhat compared to traditional MIDAS-history because each SQL table is stored into a separate file, compared to everything-in-one-file in traditional MIDAS-history.&lt;br /&gt;
&lt;br /&gt;
== Set up a MySQL database ==&lt;br /&gt;
&lt;br /&gt;
In order to setup a MySQL database, the following is needed:&lt;br /&gt;
&lt;br /&gt;
*    the server hostname and port number&lt;br /&gt;
*    database name&lt;br /&gt;
*    user name and password.&lt;br /&gt;
&lt;br /&gt;
It is recommended to create 3 different users:&lt;br /&gt;
&lt;br /&gt;
*    a &amp;quot;root&amp;quot; user with full priveleges,&lt;br /&gt;
*    a &amp;quot;reader&amp;quot; user with read-only priveleges&lt;br /&gt;
*    and a &amp;quot;writer&amp;quot; user with &amp;quot;insert, create table, and add column&amp;quot; priveleges (no permission to drop table, remove columns, etc)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
#Setup a MySQL database (RHEL/SL 5)&lt;br /&gt;
&lt;br /&gt;
 ssh root@localhost&lt;br /&gt;
 service mysqld start&lt;br /&gt;
 /usr/bin/mysql_secure_installation (enter current password for root: press &amp;lt;enter&amp;gt;, then accept  default answer &amp;quot;Y&amp;quot; to all questions)&lt;br /&gt;
 mysqladmin -p create history&lt;br /&gt;
 using mysql-administrator, create 2 users:&lt;br /&gt;
 history_writer, with database &amp;quot;history&amp;quot; schema privileges: select, insert, create, alter, index&lt;br /&gt;
 history_reader, with database &amp;quot;history&amp;quot; schema privileges: select&lt;br /&gt;
&lt;br /&gt;
#Setup $HOME/.odbc.ini file:&lt;br /&gt;
&lt;br /&gt;
 cat $HOME/.odbc.ini&lt;br /&gt;
 [history_writer]&lt;br /&gt;
 Description  = history_writer&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_writer&lt;br /&gt;
 Password     = ******&lt;br /&gt;
 [history_reader]&lt;br /&gt;
 Description  = history_reader&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_reader&lt;br /&gt;
 Password     =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: if you are using mhist you will need a separate .odbc.ini file for each user that you have connecting to the database (through MIDAS).&lt;br /&gt;
&lt;br /&gt;
== Layout of SQL tables ==&lt;br /&gt;
&lt;br /&gt;
* One table is created for each history event. Table name is the same as the history event name (as reported by [[mhdump]]).&lt;br /&gt;
* one column is created for each history tag (history variable). Column name is the same as the tag name (as reported by mhdump). For array tags, one column is created for each array element: array a[3] will produce columns a_0, a_1 and a_2.&lt;br /&gt;
* two special columns are always created: _i_time and _t_time are the timestamps in the UNIX-time integer format and in the SQL &amp;quot;time&amp;quot; format. (A priori, it is not clear which timestamp format is more useful for end users. mhttpd uses the _i_time integer time format). Note that this timestamp is the time when mlogger receives the hot-link signal (see above) and it can be a few seconds behind the time when the user placed the data into the MIDAS bank. For high precision (and sub-second time resolution) time stamps, users should generate their own timestamps and include them as part of the data itself.&lt;br /&gt;
* a special table called _history_index is created to remember the mapping between SQL names and MIDAS names for event names, variable name and tag names.&lt;br /&gt;
&lt;br /&gt;
=== Schema Evolution ===&lt;br /&gt;
&lt;br /&gt;
*    when new data fields are added, new SQL columns are created automatically&lt;br /&gt;
*    existing SQL columns are never deleted&lt;br /&gt;
*    arrays are expanded automatically, and arrays never shrink.&lt;br /&gt;
*    if the type of a data field changes, a conflict may occur with existing SQL columns, for example if previous type was &amp;quot;FLOAT&amp;quot; and new type is &amp;quot;DOUBLE&amp;quot;, the existing SQL columns would have the SQL data type &amp;quot;float&amp;quot;, too narrow to store new values. mlogger will complain about this. Such conflicts may be resolved by changing the type of the SQL column using SQL tools. In general, SQL names are created from MIDAS names by replacing all non-alphanumerical characters to an underscore &amp;quot;_&amp;quot;. If this procedure creates duplicate column names, the column names and made unique by appending them with a random number, i.e. MIDAS names &amp;quot;A+B&amp;quot; and &amp;quot;A-B&amp;quot; will be translated to &amp;quot;A_B&amp;quot; and &amp;quot;A_B_12345&amp;quot; (random integer). True MIDAS names are saved into the _history_index.&lt;br /&gt;
&lt;br /&gt;
[[Category:history]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3488</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3488"/>
		<updated>2025-04-23T21:26:22Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS == &lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3487</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3487"/>
		<updated>2025-04-23T21:25:40Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS == &lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3486</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3486"/>
		<updated>2025-04-23T21:24:53Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3485</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3485"/>
		<updated>2025-04-23T21:24:29Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
* [[# Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3484</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3484"/>
		<updated>2025-04-23T21:24:17Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
* [[Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3483</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3483"/>
		<updated>2025-04-23T21:23:45Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3482</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3482"/>
		<updated>2025-04-23T21:22:35Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3481</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3481"/>
		<updated>2025-04-23T21:21:15Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3480</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3480"/>
		<updated>2025-04-23T21:20:18Z</updated>

		<summary type="html">&lt;p&gt;Lindner: Created page with &amp;quot;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.  Setting up the    # MyAQ&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MyAQ&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3479</id>
		<title>History System</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=History_System&amp;diff=3479"/>
		<updated>2025-04-23T21:19:21Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* Write  MYSQL-history events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;&lt;br /&gt;
* [[/History ODB tree]]&lt;br /&gt;
* [[History Page]]&lt;br /&gt;
* [[Mhformat|MIDAS history file format]] &lt;br /&gt;
* [[Keys in the ODB /Logger tree|/Logger ODB tree]]&lt;br /&gt;
* [[Keys in the ODB /Logger/History subtree|/Logger/History subtree]]&lt;br /&gt;
* [[Image History]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;history file&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The history system is an add-on capability built into the MIDAS data logger [[mlogger]] to record useful information in parallel to the data logging.&lt;br /&gt;
This information is recorded with a time stamp and saved into a &#039;&#039;&#039;history file&#039;&#039;&#039;  (see [[#History drivers|History drivers]]) for later retrieval. One set of files is created per day containing all the requested history events. The history data may be displayed in graphical form using the [[mhttpd]] MIDAS webserver utility, giving the user an easy way of seeing how experimental variables have changed with time.&lt;br /&gt;
The history logging will be in action only if the MIDAS data logger is running, but it is not necessary to have any [[Keys in the ODB /Logger tree#/Logger/Channels subtree|data logging channel]] enabled.&lt;br /&gt;
&lt;br /&gt;
Since June 2020, it is possible to also use the midas history system to record images (png/jpeg etc) periodically, for example to later produce a timelapse from a webcam - see the [[Image History]] page for more details.&lt;br /&gt;
&lt;br /&gt;
= MidasHistoryInterface =&lt;br /&gt;
&lt;br /&gt;
The new history configuration defines history channels similar to logger channels. Each history channel creates a history interface class (class MidasHistoryInterface). The [[mlogger|data logger]] can use this interface to write data into the history, mhttpd, mhist &amp;amp; co can use this interface to read data from the history. The interface is defined in history.h&lt;br /&gt;
&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas/include/history.h&lt;br /&gt;
&lt;br /&gt;
= History drivers =&lt;br /&gt;
&lt;br /&gt;
Presently, the MIDAS distribution contains these drivers:&lt;br /&gt;
&lt;br /&gt;
; MIDAS-History &lt;br /&gt;
: this is the traditional history driver, with data stored in the .hst binary files. (format is documented here [[mhformat]], see also [[mhist]] and [[mhdump]])&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MIDAS subtree |&amp;quot;MIDAS&amp;quot;]]&#039;&#039;&#039; is set up to write MIDAS-history. &lt;br /&gt;
&lt;br /&gt;
; ODBC-History  &lt;br /&gt;
: stores history data in SQL database using the ODBC abstraction layer. See [[#MIDAS ODBC SQL History system|ODBC SQL History system]].&lt;br /&gt;
&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#ODBC subtree|&amp;quot;ODBC&amp;quot;]]&#039;&#039;&#039; is set up to write ODBC-history.&lt;br /&gt;
&lt;br /&gt;
; SQLITE-History &lt;br /&gt;
: stores data in SQL database as SQLITE3 .sqlite3 files. The SQL table format is similar to ODBC-history, performance is similar, no database server required.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#SQLITE subtree|&amp;quot;SQLITE&amp;quot;]]&#039;&#039;&#039; is set up to write SQLITE-history.&lt;br /&gt;
&lt;br /&gt;
; MYSQL-History&lt;br /&gt;
:&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#MYSQL subtree|&amp;quot;MYSQL&amp;quot;]]&#039;&#039;&#039; is set up to write MYSQL-history.&lt;br /&gt;
&lt;br /&gt;
; FILE-History&lt;br /&gt;
: stores each variable in its own file, making it much easier to trace the history of a particular variable.&lt;br /&gt;
: By default ODB subtree &#039;&#039;&#039;[[Keys in the ODB /Logger/History subtree#FILE subtree|FILE]]&#039;&#039;&#039; is set up to write FILE-history.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More drivers can be easily added by the user (create history_xxx.cxx, add constructor to hs_get_history(), create the ODB subtree  &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/Logger/History/xxx/channel&amp;lt;/span&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
= Location of History Files =&lt;br /&gt;
;MIDAS-history &lt;br /&gt;
:By default, the traditional MIDAS-history is enabled, writing history files into the MIDAS data directory path given by the ODB key [[Keys in the ODB /Logger tree#Data dir|Data dir]].&lt;br /&gt;
:If history data is important, it is recommended to write it to a directory that is backed up or archived. (The MIDAS data directory is usually located on a scratch data disk without backups).&lt;br /&gt;
 &lt;br /&gt;
:The location of the MIDAS-history data files can be changed by use of the ODB Key [[Keys in the ODB /Logger tree#History dir|History dir]]. &lt;br /&gt;
&lt;br /&gt;
;ODBC-History&lt;br /&gt;
:The location of ODBC-History files is ...&lt;br /&gt;
&lt;br /&gt;
;SQLITE-History &lt;br /&gt;
:The location of SQLITE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]].&lt;br /&gt;
&lt;br /&gt;
;MYSQL-History&lt;br /&gt;
:The location of MYSQL-History files is ...&lt;br /&gt;
&lt;br /&gt;
;FILE-History&lt;br /&gt;
:The location of FILE-History files is the directory path given by the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Types of History Events =&lt;br /&gt;
&lt;br /&gt;
There are two basic types of history events, which are defined in different ways:&lt;br /&gt;
&lt;br /&gt;
*    &amp;quot;[[#Frontend History Event|Frontend]]&amp;quot; (or &amp;quot;Equipment&amp;quot;) History event composed in the frontend. See [[#Frontend History Event|Frontend History Event]] for details.&lt;br /&gt;
*    &amp;quot;Virtual&amp;quot; (or &amp;quot;Links&amp;quot;) History event composed within the ODB under the  [[/History ODB tree#Links subtree|/History/Links subtree]]. See [[#Virtual History Event|Virtual History Event]] for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both these history event definitions take effect when the data logger gets a start run [[Run States and Transitions|transition]]. Any modifications made during the run are not applied until the start of the next run.&lt;br /&gt;
&lt;br /&gt;
== Virtual History Event ==&lt;br /&gt;
The history of any ODB variable can be recorded in a &amp;quot;virtual&amp;quot; history event by creating a link to that variable in the [[/History ODB tree#Links subtree|/History/Links subtree]]. This is used for ODB variables that are not in an Equipment.&lt;br /&gt;
&lt;br /&gt;
; To enable Virtual History Events&lt;br /&gt;
: Create links as desired in [[/History ODB tree#Links subtree|/History/Links subtree]].&lt;br /&gt;
&lt;br /&gt;
History events are created for each entry under ODB subdirectory {{Odbpath|path=/History/Links}}.  &lt;br /&gt;
&lt;br /&gt;
Two types of links are permitted:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; ODB key {{Odbpath|path=/history/links/aaa}} is a link to a subdirectory&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; db_watch() is setup to watch this subdirectory&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each subdirectory entry (1 tag per entry)&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt; There is no possibility for naming array elements, so 1 tag per array, regardless of the number of elements.&amp;lt;/li&amp;gt; &amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;ODB key {{Odbpath|path=/history/links/bbb}}  is a subdirectory with links to ODB values&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db_watch is setup to watch each link target&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tags are created for each link (1 tag per link)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; tag name is the link name (NOT the target name). There is no possibility for naming array elements&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mixing links and subdirectories is not permitted.&lt;br /&gt;
&lt;br /&gt;
The update period of history events created for {{Odbpath|path=/history/links}} is controlled by entries in  {{Odbpath|path=/history/links periods}}. Numeric values of periods are same as for a [[#Frontend History Event|Frontend History event]]. Numeric value 0 disables the history for a particular event.&lt;br /&gt;
&lt;br /&gt;
See [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087] for more information. &lt;br /&gt;
&lt;br /&gt;
== Frontend History Event ==&lt;br /&gt;
&lt;br /&gt;
Each  [[Frontend Operation#Equipments and Events|Equipment]] has the capability to generate &amp;quot;history data&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
; To enable Frontend History Events &lt;br /&gt;
&lt;br /&gt;
: Set the [[/Equipment ODB tree#Log history|Log history]] ODB key of each equipment to be logged &#039;&#039;&#039;non-zero&#039;&#039;&#039;. (See [[Equipment List Parameters#Log History|Log History parameter]]). (You may need to restart the frontend.)&lt;br /&gt;
&lt;br /&gt;
This causes the event contents to be copied to the  ODB [[/Equipment ODB tree#Variables subtree|/Equipment/&#039;&#039;&amp;lt;equipment-name&amp;gt;&#039;&#039;/Variables subtree]] for the use of the History system. history events are created by parsing the content of  {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/variables}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For each equipment, history is controlled by the value of {{Odbpath|path=/Equipment/&amp;lt;equipment-name&amp;gt;/common/period}} as follows:&lt;br /&gt;
* 0 = history disabled&lt;br /&gt;
* 1 = history is enabled&lt;br /&gt;
* &amp;gt;1 = history is enabled, throttled down&lt;br /&gt;
&lt;br /&gt;
The throttling is implemented in log_history()/watch_history() by this algorithm:&lt;br /&gt;
the very first history event is recorded, then all changed to the data are ignored until &amp;quot;period&amp;quot; seconds has elapsed. Then the next history event will be recorded, and following&lt;br /&gt;
changes will be ignored until &amp;quot;period&amp;quot; second elapses, and so forth. Period value &amp;quot;1&amp;quot; has special meaning - there is no throttling, all history events are logged. &lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
=== Sequence for frontend History Event ===&lt;br /&gt;
The main steps for the frontend History Event is as follows:&lt;br /&gt;
&lt;br /&gt;
* The user code in the frontend equipment Event Readout routines reads the data, placing it into a MIDAS data bank&lt;br /&gt;
* In mfe.c, if the key [[/Equipment ODB tree#Log history|Log history]] &amp;gt; 0 (i.e. the history system is enabled for this equipment), this data bank is written into ODB (by update_odb()).&lt;br /&gt;
* This ODB write triggers an ODB hot-link into mlogger&lt;br /&gt;
* The hot-link calls mlogger.c::log_history(), which calls hs_write() to write the data into the history file. The frequency of the history writes is specified by the number of seconds between writes stored in the ODB key [[/Equipment ODB tree#Log history|Log history]].&lt;br /&gt;
* history.c::hs_write() or history_odbc::hs_write_odbc() writes the data into a history file or into an SQL database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= How to Write History events =&lt;br /&gt;
*  Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
*  [[#Select the history driver|Select the history driver]]&lt;br /&gt;
*  Follow instructions below for selected driver:&lt;br /&gt;
** [[#Write MIDAS-History events|Write MIDAS-history events]]&lt;br /&gt;
** [[#Write ODBC-History events|Write ODBC-history events]]&lt;br /&gt;
** [[#Write SQLITE-History events|Write SQLITE-history events]]&lt;br /&gt;
** [[#Write MYSQL-History events|Write MYSQL-history events]]&lt;br /&gt;
** [[#Write FILE-History events|Write FILE-history events]]&lt;br /&gt;
&lt;br /&gt;
== Select the history driver ==&lt;br /&gt;
&lt;br /&gt;
* Select the  &#039;&#039;&#039;[[#History drivers|history driver]]&#039;&#039;&#039; and therefore the [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to use to write the MIDAS-history files. &lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Active|Active]] ODB key in the selected  [[Keys in the ODB /Logger/History subtree#&amp;lt;history-logging-channel&amp;gt; subtrees|history-logging-channel]]  to &amp;quot;y&amp;quot;. All other logging channels should be disabled.&lt;br /&gt;
* set  [[/History ODB tree#LoggerHistoryChannel|LoggerHistoryChannel]] ODB key to the selected [[#History drivers|History channel]].&lt;br /&gt;
&lt;br /&gt;
== Write MIDAS-History events   ==&lt;br /&gt;
* Enable desired [[#To enable Frontend History Events|Frontend]] and/or [[#To enable Virtual History Events|Virtual]] history events&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MIDAS&amp;quot;.&lt;br /&gt;
* Restart [[mhttpd]] and [[mlogger]], start the run.&lt;br /&gt;
&lt;br /&gt;
MIDAS-history files will be saved into the  [[#Location of History Files|MIDAS-history data directory]]. &lt;br /&gt;
&lt;br /&gt;
== Write ODBC-History events  ==&lt;br /&gt;
&lt;br /&gt;
See [[#MIDAS ODBC SQL History system|MIDAS ODBC SQL History system]].&lt;br /&gt;
* If necessary, [[#Set up a MySQL database|set up a MySQL database]].&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps in [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;ODBC&amp;quot;.&lt;br /&gt;
* Check ODB Key [[Keys in the ODB /Logger/History subtree#Writer_ODBC_DSN|Writer_ODBC_DSN]] is set to &amp;quot;history writer&amp;quot; and Key [[Keys in the ODB /Logger/History subtree#Reader_ODBC_DSN|Reader_ODBC_DSN]] is set to &amp;quot;history reader&amp;quot; (the default values)&lt;br /&gt;
* set [[Keys in the ODB /Logger/History subtree#Debug|Debug]] to 1 if desired&lt;br /&gt;
* restart [[mlogger]] in verbose mode (i.e. mlogger -v), and observe how it issues SQL commands to create the tables and columns corresponding to MIDAS-history events and tags.&lt;br /&gt;
* restart [[mhttpd]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&lt;br /&gt;
# [[mlogger]] is programmed to raise alarms if connection to SQL database is interrupted or if some events cannot be written into the database (i.e. data type mismatch, SQL syntax errors, etc). The traditional MIDAS-history never raised alarms because it &amp;quot;never failed&amp;quot; - other than from &amp;quot;disk full&amp;quot; errors, which are immediately obvious.&lt;br /&gt;
# With ODBC History enabled, [[mhttpd]] will only use history information from the SQL database to make history plots and to extract history variable names for the history plot editor. The ODB  {{Odbpath|path=/History}}  subtrees[[/History ODB tree#Tags subtree|Tags]] and [[/History ODB tree#Events subtree|Events]]  are not used.&lt;br /&gt;
# variable names presented to the user may change from MIDAS names to SQL names (use the history panel &amp;quot;Label&amp;quot; text fields to create permanent plot labels).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Write  SQLITE-history events  ==&lt;br /&gt;
 &lt;br /&gt;
No special configuration required. &lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Create a directory for storage of sqlite history files&lt;br /&gt;
* save its path in the ODB key  [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]&lt;br /&gt;
* restart [[mhttpd]] and [[mlogger]]&lt;br /&gt;
&lt;br /&gt;
In the history data directory (in [[Keys in the ODB /Logger/History subtree#Sqlite dir|Sqlite dir]]) you should see files with name &amp;quot;mh_xxx.sqlite3&amp;quot; corresponding to your equipment and variable names. &lt;br /&gt;
&lt;br /&gt;
== Write  MYSQL-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;MYSQL&amp;quot;.&lt;br /&gt;
* Read the following instructions to [[setup MySQL database for MIDAS]]:&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* enable MYSQL history in mlogger:&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;br /&gt;
* restart mlogger, restart mhttpd&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
== Write  FILE-history events  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Enable desired virtual and frontend history events (see [[#Virtual History Event|Virtual history events]] and [[#Frontend History Event|Frontend history events]]).&lt;br /&gt;
* Perform steps to [[#Select the history driver|Select History Driver]] with [[#History drivers|history driver]] &amp;quot;SQLITE&amp;quot;.&lt;br /&gt;
* Assign directory path for saved files using the ODB key [[Keys in the ODB /Logger/History subtree#History dir|History dir]].&lt;br /&gt;
...........&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= History Events =&lt;br /&gt;
The following information is derived from [https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087].&lt;br /&gt;
&lt;br /&gt;
A &amp;quot;history event&amp;quot; is a history atomic unit of data. Associated with each history event is a timestamp (unix time),&lt;br /&gt;
a name (limited to NAME_LENGTH in the old history) and a list of history tags that describe the individual data&lt;br /&gt;
values inside the history event.&lt;br /&gt;
&lt;br /&gt;
When making history plots in [[mhttpd]] (see [[History Page]]) for each curve on the plot, one selects a history event (from the list&lt;br /&gt;
of currently active events, recently active events or the list of all events that ever existed), then from the list of tags&lt;br /&gt;
inside the history event one selects the particular variable that will be plotted.&lt;br /&gt;
&lt;br /&gt;
== Old MIDAS history events ==&lt;br /&gt;
In the old MIDAS history, all history events are written into one history file (.hst file + optional .def and .idx event definition and time index files&lt;br /&gt;
which can be/are regenerated automatically from the .hst file). History events are identified by 16-bit history event IDs, the persistent mapping&lt;br /&gt;
from history event names and the 16-bit history event IDs is stored in ODB subtree {{Odbpath|path=/History/Events}}. In addition the list of all known history event tags is&lt;br /&gt;
stored in ODB subtree {{Odbpath|path=/History/Tags}}. For per-equipment history, the 16-bit history event ID is the value of ODB key [[/Equipment ODB tree#Event ID|/Equipment/&amp;lt;equipment-name&amp;gt;/Common/Event ID]].&lt;br /&gt;
&lt;br /&gt;
== SQL history events ==&lt;br /&gt;
In the SQL history (MySQL, SQLITE, etc), each history event is an SQL table. The history event tags are the SQL table columns.&lt;br /&gt;
&lt;br /&gt;
== FILE history events ==&lt;br /&gt;
In the new FILE history, each history event is written into a separate file, tag definition are recorded in text format in the file header, history event&lt;br /&gt;
data is appended to the file in binary format (fixed record size). If the history event definition is changed, a new file will be started.&lt;br /&gt;
&lt;br /&gt;
= History Event Construction =&lt;br /&gt;
The [[mlogger]] creates [[#Frontend history event]]s in open_history() by parsing the ODB subtree {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables}}. Each ODB entry under the {{Odbpath|path=variables/}} subtree is referred to as a &amp;quot;variable&amp;quot;. Each variable can be a single ODB value, an array of ODB values, or a subdirectory (corresponding to TID_STRUCT structured data banks). As each variable is processed, one or more tags are created to describe it. &lt;br /&gt;
&lt;br /&gt;
Single ODB values will generally produce a single tag, while arrays can produce (depending whether the array is &amp;quot;[[#Named Arrays|Named]]&amp;quot; or not)&lt;br /&gt;
* multiple tags  - one per array element (&amp;quot;Named&amp;quot; array) or&lt;br /&gt;
* one single tag - describing the whole array  &lt;br /&gt;
 &lt;br /&gt;
The code can generate two types of history:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-equipment&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have the tags for all variables concatenated together into one single history event&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt; &amp;quot;per-variable&amp;quot; history&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; will have one history event defined for each variable. Inside could be one tag (for single odb values and unnamed array)  or multiple tags (for named arrays and structured data &lt;br /&gt;
banks).&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per-equipment history is the original MIDAS history implementation. Per-variable history was added to permit efficient data storage in SQL tables. Its initial implementation used 1 ODB hotlink for each variable and it was easy to exceed the maximum permitted number of ODB hotlinks (db_open_record()). To reduce consumption of hotlinks, db_watch() has been implemented and now per-variable history only uses 1 ODB hotlink per equipment.&lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: With db_watch, per-equipment history is no longer available. &#039;&#039;&#039;Per-variable history is the new default&#039;&#039;&#039; (and the only option).&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/elog/Midas/1087 MidasElog#1087]&lt;br /&gt;
&lt;br /&gt;
= Construction of history event tags =&lt;br /&gt;
Currently,&lt;br /&gt;
* single ODB values are treated as arrays of length &amp;quot;1&amp;quot;&lt;br /&gt;
* string ODB entries are not permitted&lt;br /&gt;
&lt;br /&gt;
History event tags are constructed in the [[mlogger]] add_equipment(). Presently there are some quirks with the generation of history event tags (see  [https://midas.triumf.ca/elog/Midas/1088]),&lt;br /&gt;
e.g. single odb values are treated as arrays of length &amp;quot;1&amp;quot; and  &amp;quot;string&amp;quot; ODB entries are not permitted.&lt;br /&gt;
&lt;br /&gt;
For variables of type TID_KEY (subdirectories, corresponding to TID_STRUCT structured banks), one tag is generated for each subdirectory entry. Tag names for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa/bbb}} will be &amp;quot;aaa_bbb&amp;quot; (with an underscore). Subdirectory entries of type TID_KEY and TID_LINK are currently not supported.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Named Arrays]]&amp;quot;, individual tags are generated for each array element. Tag names are taken from the &#039;&#039;Names&#039;&#039; array. For empty tag names (empty names array), tags are &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc (for {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}). &lt;br /&gt;
&lt;br /&gt;
For &amp;quot;[[#Named Arrays|Single Names Arrays]]&amp;quot;, tag names have the variable name appended (with a space), for  {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and an empty names array, tags will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, etc. For a populated names array, the tags will be &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
For unnamed arrays and single odb variables (in ODB, single odb variables are arrays of length 1), a single tag is generated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Named Arrays ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Named Arrays&#039;&#039;&#039; have a &amp;quot;Names&amp;quot; entry in {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings}}.&lt;br /&gt;
&lt;br /&gt;
For example, to add names to {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}}, create a string array {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names aaa}}. The names array should be at least as long as the corresponding data array. Individual entries in the names array can be left blank (tag names will be &amp;quot;aaa_0&amp;quot;, &amp;quot;aaa_1&amp;quot;, etc). Duplicate tag names are not permitted.&lt;br /&gt;
&lt;br /&gt;
A single &amp;quot;Names&amp;quot; entry can be created to name all arrays in variables with the same names (&#039;&#039;&#039;&amp;quot;Single Names&amp;quot;&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Create {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/settings/names}} and arrays {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/aaa}} and {{Odbpath|path=/equipment/&amp;lt;equipment-name&amp;gt;/variables/bbb}} will have &lt;br /&gt;
history tags &amp;quot;name0 aaa&amp;quot;, &amp;quot;name1 aaa&amp;quot;, &amp;quot;name0 bbb&amp;quot;, &amp;quot;name1 bbb&amp;quot;, etc. If &amp;quot;names&amp;quot; are left blank, tag names will be &amp;quot;aaa_0 aaa&amp;quot;, &amp;quot;aaa_1 aaa&amp;quot;, &amp;quot;bbb_0 bbb&amp;quot;, &amp;quot;bbb_1 bbb&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
In the [[mhttpd]] web server [[History Page]] variables viewer, &amp;quot;single name&amp;quot; arrays are displayed in a 2D table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This information is from [https://midas.triumf.ca/elog/Midas/1088].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Historical note on MIDAS-History Tag names =&lt;br /&gt;
Tags are only used for MIDAS-history events. &lt;br /&gt;
&lt;br /&gt;
The mlogger/mhttpd implementation of &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; has proved troublesome and we are moving away from it.&lt;br /&gt;
&lt;br /&gt;
;During the transition period:&lt;br /&gt;
:   Implementations starting with Version 4435 of [[mlogger]] and [[mhttpd]] (i.e. &amp;quot;new&amp;quot; versions) will now work &#039;&#039;&#039;without&#039;&#039;&#039; &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt;. The history tags are read directly from the history files themselves. To run in this mode, set  ODB key [[/History ODB tree#DisableTags|/History/DisableTags]] to &amp;quot;y&amp;quot;. Existing [[/History ODB tree#Tags subtree|/History/Tags subtree]] will be automatically deleted.&lt;br /&gt;
&lt;br /&gt;
Two downsides to running like this are&lt;br /&gt;
* it is slower and tags become non-persistent&lt;br /&gt;
* if some frontends have not been running for a while, their variables may vanish from the history panel editor.&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
== New-style History Tags ==&lt;br /&gt;
For the above two reasons, using &amp;lt;span style=&amp;quot;color:purple; font-style:italic&amp;quot;&amp;gt;/History/Tags&amp;lt;/span&amp;gt; is still recommended.  &lt;br /&gt;
However, the format of the tags is now changed to simplify management and reduce ODB size. &lt;br /&gt;
&lt;br /&gt;
; For NEW implementations&lt;br /&gt;
: the key [[/History ODB tree#CreateOldTags|CreateOldTags]] will not be present. &amp;quot;New-style&amp;quot; history tags will be created automatically in the [[/History ODB tree#Tags subtree|Tags subtree]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;If you have old-style tags&lt;br /&gt;
: [[mlogger]] will automatically convert the old tags to this new format (this is why you should make a backup of your ODB).&lt;br /&gt;
&lt;br /&gt;
** using &amp;quot;old&amp;quot; (i.e. pre Version 4435) mlogger with &amp;quot;new&amp;quot; mhttpd is OK: new mhttpd understands both formats of /History/Tags.&lt;br /&gt;
** using &amp;quot;old&amp;quot; mhttpd with &amp;quot;new&amp;quot; mlogger is OK provided the ODB key [[/History ODB tree#CreateOldTags|/History/CreateOldTags]] is set to &amp;quot;y&amp;quot; before starting mlogger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Old-style History Tags ==&lt;br /&gt;
Prior to versions 4435 of [[mlogger]] and [[mhttpd]], old-style history tags were generated.&lt;br /&gt;
See&lt;br /&gt;
* http://ladd00.triumf.ca/~daqweb/doc/midas-old/html/F_History_logging.html&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
---------------&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= MIDAS ODBC SQL History system =&lt;br /&gt;
&lt;br /&gt;
This section describes the internal workings of the MIDAS SQL history system.&lt;br /&gt;
&lt;br /&gt;
The SQL history system implements the MIDAS history using a SQL database for data storage instead of flat binary files.&lt;br /&gt;
&lt;br /&gt;
The SQL history code lives in a separate files history.h and history_sql.cxx. The present implementation uses the ODBC API for accessing SQL databases. &lt;br /&gt;
MySQL is fully supported, Pgsql support is partially implemented, support for arbitrary ODBC drivers should be easy to add in history_sql and most SQL operations are done using an interface class.&lt;br /&gt;
&lt;br /&gt;
Preliminary testing with MySQL and PgSQL indicates that disk space requirements are the same for both storage mechanisms using flat binary files or either of the 2 SQL databases. All 3 tested storage mechanisms store the data uncompressed. (Observed gzip-1 compression ratios from CERN-ALPHA history files are 50% or better).&lt;br /&gt;
&lt;br /&gt;
Preliminary testing also indicates that MySQL database is &amp;quot;not too slow&amp;quot; for use by T2K/ND280 slow control system. Using MySQL, performance seems to improve somewhat compared to traditional MIDAS-history because each SQL table is stored into a separate file, compared to everything-in-one-file in traditional MIDAS-history.&lt;br /&gt;
&lt;br /&gt;
== Set up a MySQL database ==&lt;br /&gt;
&lt;br /&gt;
In order to setup a MySQL database, the following is needed:&lt;br /&gt;
&lt;br /&gt;
*    the server hostname and port number&lt;br /&gt;
*    database name&lt;br /&gt;
*    user name and password.&lt;br /&gt;
&lt;br /&gt;
It is recommended to create 3 different users:&lt;br /&gt;
&lt;br /&gt;
*    a &amp;quot;root&amp;quot; user with full priveleges,&lt;br /&gt;
*    a &amp;quot;reader&amp;quot; user with read-only priveleges&lt;br /&gt;
*    and a &amp;quot;writer&amp;quot; user with &amp;quot;insert, create table, and add column&amp;quot; priveleges (no permission to drop table, remove columns, etc)&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
#Setup a MySQL database (RHEL/SL 5)&lt;br /&gt;
&lt;br /&gt;
 ssh root@localhost&lt;br /&gt;
 service mysqld start&lt;br /&gt;
 /usr/bin/mysql_secure_installation (enter current password for root: press &amp;lt;enter&amp;gt;, then accept  default answer &amp;quot;Y&amp;quot; to all questions)&lt;br /&gt;
 mysqladmin -p create history&lt;br /&gt;
 using mysql-administrator, create 2 users:&lt;br /&gt;
 history_writer, with database &amp;quot;history&amp;quot; schema privileges: select, insert, create, alter, index&lt;br /&gt;
 history_reader, with database &amp;quot;history&amp;quot; schema privileges: select&lt;br /&gt;
&lt;br /&gt;
#Setup $HOME/.odbc.ini file:&lt;br /&gt;
&lt;br /&gt;
 cat $HOME/.odbc.ini&lt;br /&gt;
 [history_writer]&lt;br /&gt;
 Description  = history_writer&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_writer&lt;br /&gt;
 Password     = ******&lt;br /&gt;
 [history_reader]&lt;br /&gt;
 Description  = history_reader&lt;br /&gt;
 Driver       = /usr/lib64/libmyodbc3.so&lt;br /&gt;
 SERVER       = ladd05.triumf.ca&lt;br /&gt;
 PORT         =&lt;br /&gt;
 Database     = history&lt;br /&gt;
 OPTION       = 3&lt;br /&gt;
 SOCKET       =&lt;br /&gt;
 User         = history_reader&lt;br /&gt;
 Password     =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: if you are using mhist you will need a separate .odbc.ini file for each user that you have connecting to the database (through MIDAS).&lt;br /&gt;
&lt;br /&gt;
== Layout of SQL tables ==&lt;br /&gt;
&lt;br /&gt;
* One table is created for each history event. Table name is the same as the history event name (as reported by [[mhdump]]).&lt;br /&gt;
* one column is created for each history tag (history variable). Column name is the same as the tag name (as reported by mhdump). For array tags, one column is created for each array element: array a[3] will produce columns a_0, a_1 and a_2.&lt;br /&gt;
* two special columns are always created: _i_time and _t_time are the timestamps in the UNIX-time integer format and in the SQL &amp;quot;time&amp;quot; format. (A priori, it is not clear which timestamp format is more useful for end users. mhttpd uses the _i_time integer time format). Note that this timestamp is the time when mlogger receives the hot-link signal (see above) and it can be a few seconds behind the time when the user placed the data into the MIDAS bank. For high precision (and sub-second time resolution) time stamps, users should generate their own timestamps and include them as part of the data itself.&lt;br /&gt;
* a special table called _history_index is created to remember the mapping between SQL names and MIDAS names for event names, variable name and tag names.&lt;br /&gt;
&lt;br /&gt;
=== Schema Evolution ===&lt;br /&gt;
&lt;br /&gt;
*    when new data fields are added, new SQL columns are created automatically&lt;br /&gt;
*    existing SQL columns are never deleted&lt;br /&gt;
*    arrays are expanded automatically, and arrays never shrink.&lt;br /&gt;
*    if the type of a data field changes, a conflict may occur with existing SQL columns, for example if previous type was &amp;quot;FLOAT&amp;quot; and new type is &amp;quot;DOUBLE&amp;quot;, the existing SQL columns would have the SQL data type &amp;quot;float&amp;quot;, too narrow to store new values. mlogger will complain about this. Such conflicts may be resolved by changing the type of the SQL column using SQL tools. In general, SQL names are created from MIDAS names by replacing all non-alphanumerical characters to an underscore &amp;quot;_&amp;quot;. If this procedure creates duplicate column names, the column names and made unique by appending them with a random number, i.e. MIDAS names &amp;quot;A+B&amp;quot; and &amp;quot;A-B&amp;quot; will be translated to &amp;quot;A_B&amp;quot; and &amp;quot;A_B_12345&amp;quot; (random integer). True MIDAS names are saved into the _history_index.&lt;br /&gt;
&lt;br /&gt;
[[Category:history]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3462</id>
		<title>MidasWiki:Community portal</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3462"/>
		<updated>2025-01-20T20:45:42Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Our main forum for exchanging information about MIDAS is an ELOG list, available here&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/forum https://midas.triumf.ca/forum]&lt;br /&gt;
&lt;br /&gt;
All users of MIDAS are encouraged to sign-up for the ELOG forum.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
There is a [https://midas.triumf.ca/MidasWiki/index.php/FAQ FAQ on this wiki].&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from the [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop],  [https://indico.triumf.ca/event/428/ 2017 MIDAS Workshop], [https://indico.triumf.ca/event/429/ 2019 MIDAS Workshop] and [https://indico.psi.ch/event/15025/timetable/#20230912 2023 MIDAS workshop]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3461</id>
		<title>MidasWiki:Community portal</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3461"/>
		<updated>2025-01-20T20:45:21Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Our main forum for exchanging information about MIDAS is an ELOG list, available here&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/forum https://midas.triumf.ca/forum]&lt;br /&gt;
&lt;br /&gt;
All users of MIDAS are encouraged to sign-up for the ELOG forum.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
There is a [https://midas.triumf.ca/MidasWiki/index.php/FAQ FAQ on this wiki].&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from the [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop],  [https://indico.triumf.ca/conferenceDisplay.py?confId=2342 2017 MIDAS Workshop], [https://indico.triumf.ca/event/429/ 2019 MIDAS Workshop] and [https://indico.psi.ch/event/15025/timetable/#20230912 2023 MIDAS workshop]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3460</id>
		<title>MidasWiki:Community portal</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MidasWiki:Community_portal&amp;diff=3460"/>
		<updated>2025-01-20T20:44:44Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Our main forum for exchanging information about MIDAS is an ELOG list, available here&lt;br /&gt;
&lt;br /&gt;
[https://midas.triumf.ca/forum https://midas.triumf.ca/forum]&lt;br /&gt;
&lt;br /&gt;
All users of MIDAS are encouraged to sign-up for the ELOG forum.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
There is a [https://midas.triumf.ca/MidasWiki/index.php/FAQ FAQ on this wiki].&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from the [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop],  [https://indico.triumf.ca/conferenceDisplay.py?confId=2342 2017 MIDAS Workshop], [https://indico.triumf.ca/conferenceDisplay.py?confId=2438 2019 MIDAS Workshop] and [https://indico.psi.ch/event/15025/timetable/#20230912 2023 MIDAS workshop]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3229</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3229"/>
		<updated>2023-06-09T22:52:58Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3228</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3228"/>
		<updated>2023-06-09T20:01:06Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://bitbucket.com/tmidas/midas Bitbucket Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://indico.triumf.ca/conferenceDisplay.py?confId=2438 2019 MIDAS Workshop]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3227</id>
		<title>MIDAS Workshops</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3227"/>
		<updated>2023-06-09T19:48:48Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* 2017 Midas workshop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy of 2017 and 2019 MIDAS workshop slides&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2017 Midas workshop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stefan Ritt - &lt;br /&gt;
[[File:Stefan_introduction.pdf|thumb|introduction]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3226</id>
		<title>MIDAS Workshops</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3226"/>
		<updated>2023-06-09T19:48:30Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* 2017 Midas workshop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy of 2017 and 2019 MIDAS workshop slides&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2017 Midas workshop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stefan Ritt - &lt;br /&gt;
[[File:Stefan_introduction.pdf|thumb|introduction]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://daq00.triumf.ca/MidasWiki/index.php/File:Stefan_introduction.pdf&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=File:Stefan_introduction.pdf&amp;diff=3225</id>
		<title>File:Stefan introduction.pdf</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=File:Stefan_introduction.pdf&amp;diff=3225"/>
		<updated>2023-06-09T19:46:50Z</updated>

		<summary type="html">&lt;p&gt;Lindner: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3224</id>
		<title>MIDAS Workshops</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3224"/>
		<updated>2023-06-09T19:43:49Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* 2017 Midas workshop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy of 2017 and 2019 MIDAS workshop slides&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2017 Midas workshop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stefan Ritt - &lt;br /&gt;
[[File:Stefan introduction|thumb|introduction]]&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3223</id>
		<title>MIDAS Workshops</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=MIDAS_Workshops&amp;diff=3223"/>
		<updated>2023-06-09T17:58:25Z</updated>

		<summary type="html">&lt;p&gt;Lindner: /* 2017 Midas workshop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy of 2017 and 2019 MIDAS workshop slides&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2017 Midas workshop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stefan Ritt - Introduction&lt;/div&gt;</summary>
		<author><name>Lindner</name></author>
	</entry>
</feed>