The file is used multiple times:
- By the backend to find the MySQL database - otherweise a built-in default is used: [778249a]
- By the frontend to find its backend; otherwise the frontend tries to find a backend using UPnP.
- By other mythProgramsNames to locate the backend e.g. mythshutdown.
Depending on the distribution and or local choices, the file may be found in: /etc/mythtv/config.xml, ~/.mythtv/config.xml or ~mythtv/.mythtv/config.xml etc.
The proper way to get the actual location is to look under $HOME/.mythtv of the user running a MythTV program. Typically, the user that runs the backend is mythtv. Frontends may be run as the login user name. Note that if MYTHCONFDIR is set, it overrides the setting of HOME.
To find which environmental variable is used, and therefore the actual location, users should look at the values of HOME and possibly MYTHCONFDIR of the program being run. This includes any scripts/systemd .system files/Upstart .conf files. If a program is being run from the command line, simply type: echo "HOME=$HOME, MYTHCONFDIR=$MYTHCONFDIR" to see what's set.
Before 0.26, mysql.txt was used. It is no longer required by MythTV. It is possible that some non-compliant 3rd party programs still reference it. MythTV 0.26.
The following template can be found in mythtv/contrib/config_files/config.xml
<Configuration> <UPnP> <UDN> <MediaRenderer>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</MediaRenderer> </UDN> </UPnP> <LocalHostName>my-unique-identifier-goes-here</LocalHostName> <Database> <PingHost>1</PingHost> <Host>127.0.0.1</Host> <UserName>mythtv</UserName> <Password>mythtv</Password> <DatabaseName>mythconverg</DatabaseName> <Port>3306</Port> </Database> <WakeOnLAN> <Enabled>0</Enabled> <SQLReconnectWaitTime>0</SQLReconnectWaitTime> <SQLConnectRetry>5</SQLConnectRetry> <Command>echo 'WOLsqlServerCommand not set'</Command> </WakeOnLAN> </Configuration>
- The unique name used to look-up host-specific settings. By default the system's hostname is used and this shouldn't be changed, but it can be useful to overwrite this when the hostname is changed or multiple frontends with different configurations should run on the same host.
- The UUID used for the MythTV frontend, when used as a UPnP media renderer.
- These settings are deprecated by the settings below mythtv/libs/libmyth/mythcontext.cpp.
All configuration data is stored in a central MySQL database, which must be reachable for all MythTV components.
- 1=MythTV should try to test-ping the host running the database using ICMP echo-request before actually connecting the database process; usually 1.
- The hostname, IPv4 or IPv6 address of the host, where the database is running. Note that if the database and master backend are running on the same machine (very typical), the value should be localhost or 127.0.0.1.
- The name of the account used to authenticate against the database; usually mythtv.
- The password used to authenticate.
- The name of the schema of the database; usually mythconverg.
- The TCP port number, where the database is running on; usually 3306.
If the database is unreachable, MythTV can try to wake up the host using for example Wake-on-LAN.
- 1=MythTV should try to wake up the host. PingHost=1 must be set as well!
- Seconds to wait between reconnection attempts.
- Number of times to retry; usually 5.
- Command to use to wake server; for example sudo etherwake xx:xx:xx:xx:xx:xx.
A bit of a long winded discussion attempting to answer questions about the file and how it's accessed.
By design, the location of the config.xml file used by MythTV programs is very flexible. This is great for users with multiple backends, testers and developers. It can, however, cause problems for basic users.
A common report in the MythTV Forums, mailing lists and IRC is that starting a user's frontend results in repeated attempts to set the language etc. Users have also reported that starting their backend from the command line behaves differently then when started by their init script.
What's Going On?
In most cases, the cause is that different config.xml files containing different information are being used.
For example, if the backend is started by user mythtv but the frontend is started as the login user AND they have separate config.xml files, bad things can happen.
A simple test to compare the contents is:
diff ~mythtv/.mythtv/config.xml ~/.mythtv/config.xml
Use the values in the config.xml that allow logging into the database.
Swell, so which config.xml file is being used
Great question and there's a simple answer. Look in the log file for the program being run. There will be a line containing text similar to this:
... Using configuration directory = /home/mythtv/.mythtv
Of course, it's good if the user running a program can write to the file.
And how did the configuration directory get selected?
This is a bit harder. MythTV programs begin by looking at the value stored in the HOME environmental variable.
Next, they check the MYTHCONFDIR variable and if present, it overrides the value in HOME.
That's not too bad, but here's the hard part. It's not unusual for distributions to alter the environment in init service, configuration or scripts that start the mythbackend. The same is true for things that start mythfrontend. Here are some specific examples of files used to start mythbackend at boot time:
/etc/init.d/mythtv-backend.sh /etc/init/mythtv-backend.conf /lib/systemd/system/mythtv-backend.service /etc/rc.local
The 1st is ancient, the 2nd is used by *buntu prior to version 15.10 and the 3rd is now the standard. The 4th is there because it's use has been observed in the wild, but doesn't seem to be very common.
Finding the location of where mythfrontend sets the environment needs to be added. Esp. by some kind Mythbuntu user.
A note for newcomers
This is really 'basic unix, but a special type of file is a link. Similar to a shortcut in the Windows world. When looking at the files mentioned above using the ls -ld <some path to>/config.xml command, a link to some other file may be found. That's perfectly fine. It's even desirable because both the mythtv and login user can have their files point to a common location e.g. /etc/mythtv/config.xml. It's also possible (and frequently heard of) that one of the links gets broken! Follow the concepts above to locate which file is in use and then take care to look at the output of the ls command.